Skip to content

Backport IMAP test modernization to PHP-8.0 branch #6476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions azure/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ steps:
set -e
sudo groupadd -g 5000 vmail
sudo useradd -m -d /var/vmail -s /bin/false -u 5000 -g vmail vmail
sudo cp ext/imap/tests/dovecot.conf /etc/dovecot/dovecot.conf
sudo cp ext/imap/tests/dovecotpass /etc/dovecot/dovecotpass
sudo cp ext/imap/tests/setup/dovecot.conf /etc/dovecot/dovecot.conf
sudo cp ext/imap/tests/setup/dovecotpass /etc/dovecot/dovecotpass
sudo service dovecot restart
displayName: 'Configure IMAP'

1 change: 0 additions & 1 deletion ext/imap/tests/CONFLICTS

This file was deleted.

6 changes: 3 additions & 3 deletions ext/imap/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ hMailServer on Windows. The tests are intended to be mailserver agnostic.

## Set-up tests on Ubuntu (checked on Ubuntu 18.04 (Bionic))
The necessary packages can be installed using the following command;
`apt-get install libc-client-dev libkrb5-dev dovecot-core dovecot-pop3d dovecot-imapd`
`apt-get install libc-client-dev libkrb5-dev dovecot-core dovecot-pop3d dovecot-imapd sendmail`

The build of PHP will need to be compiled with the following flags:
```
--with-imap --with-kerberos --with-imap-ssl
```

Then run the set-up script `ext/imap/tests/setup.sh` which will add the `vmail`
Then run the set-up script `ext/imap/tests/setup/setup.sh` which will add the `vmail`
group and user which is used by Dovecot for the mailbox. It will also copy the
`ext/imap/tests/dovecot.conf` and `ext/imap/tests/dovecotpass` to the correct
`ext/imap/tests/setup/dovecot.conf` and `ext/imap/tests/setup/dovecotpass` to the correct
location for Dovecot and restarts it for the new configuration to be enabled.
4 changes: 1 addition & 3 deletions ext/imap/tests/bug31142_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Bug #31142 test #2 (imap_mail_compose() generates incorrect output)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
Expand Down
4 changes: 1 addition & 3 deletions ext/imap/tests/bug32589.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Bug #32589 (crash inside imap_mail_compose() function)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
Expand Down
56 changes: 27 additions & 29 deletions ext/imap/tests/bug35669.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,43 @@
Bug #35669 (imap_mail_compose() crashes with multipart-multiboundary-email)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
$envelope["from"] = 'Santa <somewhere@northpole.gov>';
$envelope["to"] = 'The bad smurf <bad@smurf.com>';
$envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';
$envelope["from"] = 'Santa <somewhere@northpole.gov>';
$envelope["to"] = 'The bad smurf <bad@smurf.com>';
$envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';

$multipart["type"] = TYPEMULTIPART;
$multipart["subtype"] = "MIXED";
$body[] = $multipart; //add multipart stuff
$multipart["type"] = TYPEMULTIPART;
$multipart["subtype"] = "MIXED";
$body[] = $multipart; //add multipart stuff

$textpart["type"] = TYPEMULTIPART;
$textpart["subtype"] = "ALTERNATIVE";
$body[] = $textpart; //add body part
$textpart["type"] = TYPEMULTIPART;
$textpart["subtype"] = "ALTERNATIVE";
$body[] = $textpart; //add body part

$plain["type"] = TYPETEXT;
$plain["subtype"] = "PLAIN";
$plain["charset"] = "iso-8859-1";
$plain["encoding"] = ENCQUOTEDPRINTABLE;
$plain["description"] = "Plaintype part of message";
$plain['disposition'] = "inline";
$plain["contents.data"] = 'See mom, it will crash';
$plain["type"] = TYPETEXT;
$plain["subtype"] = "PLAIN";
$plain["charset"] = "iso-8859-1";
$plain["encoding"] = ENCQUOTEDPRINTABLE;
$plain["description"] = "Plaintype part of message";
$plain['disposition'] = "inline";
$plain["contents.data"] = 'See mom, it will crash';

$body[] = $plain; //next add plain text part
$body[] = $plain; //next add plain text part

$html["type"] = TYPETEXT;
$html["subtype"] = "HTML";
$html["charset"] = "iso-8859-1";
$html["encoding"] = ENCQUOTEDPRINTABLE;
$html["description"] = "HTML part of message";
$html['disposition'] = "inline";
$html["contents.data"] = 'See mom, it will <b>crash</b>';
$html["type"] = TYPETEXT;
$html["subtype"] = "HTML";
$html["charset"] = "iso-8859-1";
$html["encoding"] = ENCQUOTEDPRINTABLE;
$html["description"] = "HTML part of message";
$html['disposition'] = "inline";
$html["contents.data"] = 'See mom, it will <b>crash</b>';

$body[] = $html;
$body[] = $html;

echo imap_mail_compose($envelope, $body);
echo imap_mail_compose($envelope, $body);
?>
--EXPECTF--
Date: Wed, 04 Jan 2006 19:24:43 -0500
Expand Down
13 changes: 4 additions & 9 deletions ext/imap/tests/bug44098.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
Bug #44098 (imap_utf8() returns only capital letters)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
$exp = 'Luzon®14 dot CoM';
$res = imap_utf8('=?iso-8859-1?b?THV6b26uMTQ=?= dot CoM');
if ($res != $exp) {
echo "failed: got <$res>, expected <exp>\n";
} else {
echo "ok";
}
var_dump($res);

?>
--EXPECT--
ok
string(17) "Luzon®14 dot CoM"
4 changes: 1 addition & 3 deletions ext/imap/tests/bug45705_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Bug #45705 test #1 (imap rfc822_parse_adrlist() modifies passed address parameter)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
Expand Down
4 changes: 1 addition & 3 deletions ext/imap/tests/bug45705_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Bug #45705 test #2 (imap rfc822_parse_adrlist() modifies passed address parameter)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
Expand Down
4 changes: 1 addition & 3 deletions ext/imap/tests/bug53377.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Bug #53377 (imap_mime_header_decode() doesn't ignore \t during long MIME header unfolding)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--FILE--
<?php
Expand Down
13 changes: 8 additions & 5 deletions ext/imap/tests/bug63126.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ imap_open() DISABLE_AUTHENTICATOR ignores array param
<?php
extension_loaded('imap') or die('skip imap extension not available in this build');

require_once(__DIR__.'/imap_include.inc');
require_once(__DIR__. '/setup/imap_include.inc');

$in = @imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1);
$in = @imap_open(IMAP_SERVER_DEBUG, IMAP_MAILBOX_USERNAME, IMAP_MAILBOX_PASSWORD, OP_HALFOPEN, 1);
if (!$in) {
die("skip could not connect to mailbox $default_mailbox");
die("skip could not connect to mailbox " . IMAP_SERVER_DEBUG);
}
$kerberos = false;
if (is_array($errors = imap_errors())) {
Expand All @@ -22,16 +22,19 @@ if (!$kerberos) {
die("skip need a GSSAPI/Kerberos aware server");
}
?>
--CONFLICTS--
defaultmailbox
--FILE--
<?php
// TODO Test Kerberos on CI
$tests = array(
'Array' => array('DISABLE_AUTHENTICATOR' => array('GSSAPI','NTLM')),
'String' => array('DISABLE_AUTHENTICATOR' => 'GSSAPI'),
);
require_once(__DIR__.'/imap_include.inc');
require_once(__DIR__. '/setup/imap_include.inc');
foreach ($tests as $name => $testparams) {
echo "Test for $name\n";
$in = imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1, $testparams);
$in = imap_open(IMAP_SERVER_DEBUG, IMAP_MAILBOX_USERNAME, IMAP_MAILBOX_PASSWORD, OP_HALFOPEN, 1, $testparams);
if ($in) {
if (is_array($errors = imap_errors())) {
foreach ($errors as $err) {
Expand Down
11 changes: 6 additions & 5 deletions ext/imap/tests/bug64076.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
Bug #64076 (imap_sort() does not return FALSE on failure)
--SKIPIF--
<?php
require_once __DIR__ . '/skipif.inc';
require_once __DIR__ . '/setup/skipif.inc';
?>
--FILE--
<?php
require_once __DIR__ . '/imap_include.inc';
$stream = setup_test_mailbox('', 2);
require_once __DIR__ . '/setup/imap_include.inc';
$stream = setup_test_mailbox('bug64076', 2);
imap_errors(); // clear error stack
var_dump(imap_sort($stream, SORTFROM, 0, 0, 'UNSUPPORTED SEARCH CRITERIUM'));
var_dump(imap_errors() !== false);
?>
--CLEAN--
<?php
require_once __DIR__ . '/clean.inc';
$mailbox_suffix = 'bug64076';
require_once(__DIR__ . '/setup/clean.inc');
?>
--EXPECT--
Create a temporary mailbox and add 2 msgs
.. mailbox '{127.0.0.1:143/norsh}INBOX.phpttest' created
New mailbox created
bool(false)
bool(true)
6 changes: 3 additions & 3 deletions ext/imap/tests/bug77020.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail('1', 1, NULL);
@imap_mail('1', 1, NULL);
echo 'done'
?>
--EXPECTF--
Warning: imap_mail(): No message string in mail command in %s on line %d
%S
%Adone
10 changes: 5 additions & 5 deletions ext/imap/tests/bug77153.phpt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--TEST--
--TEST--
Bug #77153 (imap_open allows to run arbitrary shell commands via mailbox parameter)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
extension_loaded('imap') or die('skip imap extension not available in this build');
?>
--CONFLICTS--
defaultmailbox
--FILE--
<?php
$payload = "echo 'BUG'> " . __DIR__ . '/__bug';
Expand All @@ -21,4 +21,4 @@ bool(false)
--CLEAN--
<?php
if(file_exists(__DIR__ . '/__bug')) unlink(__DIR__ . '/__bug');
?>
?>
7 changes: 6 additions & 1 deletion ext/imap/tests/bug80213.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ $body = [[
'type.parameters' => ['param'],
'disposition' => ['disp'],
]];
imap_mail_compose($envelope, $body);
var_dump(imap_mail_compose($envelope, $body));
echo "done\n";
?>
--EXPECT--
string(67) "MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII


"
done
21 changes: 17 additions & 4 deletions ext/imap/tests/bug80226.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@
Bug #80226 (imap_sort() leaks sortpgm memory)
--SKIPIF--
<?php
require_once(__DIR__.'/skipif.inc');
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
require_once(__DIR__.'/imap_include.inc');
$stream = imap_open($default_mailbox, $username, $password);
imap_sort($stream, SORTFROM, 0);
require_once(__DIR__.'/setup/imap_include.inc');

echo "Create a new mailbox for test\n";

$stream = setup_test_mailbox("bug80226", 0);
var_dump(imap_sort($stream, SORTFROM, 0));
?>
--CLEAN--
<?php
$mailbox_suffix = 'bug80226';
require_once(__DIR__ . '/setup/clean.inc');
?>
--EXPECT--
Create a new mailbox for test
Create a temporary mailbox and add 0 msgs
New mailbox created
array(0) {
}
4 changes: 1 addition & 3 deletions ext/imap/tests/bug80438.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
--SKIPIF--
<?php
require_once(__DIR__.'/skipif.inc');
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
echo "*** Testing imap_fetch_overview() : basic functionality ***\n";

require_once __DIR__.'/setup/imap_include.inc';

Expand Down Expand Up @@ -41,7 +40,6 @@ $mailbox_suffix = 'bug80438';
require_once __DIR__.'/setup/clean.inc';
?>
--EXPECT--
*** Testing imap_fetch_overview() : basic functionality ***
Create a temporary mailbox and add 10 msgs
New mailbox created
array(6) {
Expand Down
25 changes: 0 additions & 25 deletions ext/imap/tests/clean.inc

This file was deleted.

Loading