summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-11-29 17:43:03 +0100
committerGitHub <noreply@github.com>2018-11-29 17:43:03 +0100
commitee2cb46cdc161fc0e90f4c9bea40607511d1087e (patch)
treee0a6e0eaf2d2f5e2b3d18a582f9bd3aae438cebc /tests
parentf77e519137d8b934ce599548a0ce3bdd81b826a2 (diff)
parent4a2c56b71400de7a044e0a3c05a62ae34c4c4d69 (diff)
downloadnextcloud-server-ee2cb46cdc161fc0e90f4c9bea40607511d1087e.tar.gz
nextcloud-server-ee2cb46cdc161fc0e90f4c9bea40607511d1087e.zip
Merge pull request #12424 from nextcloud/feature/add-pipe-mode-for-sendmail
Add pipe mode for sendmail
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/MailSettingsControllerTest.php8
-rw-r--r--tests/lib/Mail/MailerTest.php50
-rw-r--r--tests/lib/Settings/Admin/MailTest.php6
3 files changed, 50 insertions, 14 deletions
diff --git a/tests/Settings/Controller/MailSettingsControllerTest.php b/tests/Settings/Controller/MailSettingsControllerTest.php
index 79fe0683cc5..ed241ed0533 100644
--- a/tests/Settings/Controller/MailSettingsControllerTest.php
+++ b/tests/Settings/Controller/MailSettingsControllerTest.php
@@ -74,6 +74,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mail_smtpauthtype' => 'NTLM',
'mail_smtpauth' => 1,
'mail_smtpport' => '25',
+ 'mail_sendmailmode' => null,
]],
[[
'mail_domain' => 'nextcloud.com',
@@ -86,6 +87,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mail_smtpport' => '25',
'mail_smtpname' => null,
'mail_smtppassword' => null,
+ 'mail_sendmailmode' => null,
]]
);
@@ -98,7 +100,8 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mx.nextcloud.org',
'NTLM',
1,
- '25'
+ '25',
+ null
);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
@@ -111,7 +114,8 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mx.nextcloud.org',
'NTLM',
0,
- '25'
+ '25',
+ null
);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index ddae38ff54d..4117498885c 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -48,30 +48,54 @@ class MailerTest extends TestCase {
);
}
- public function testGetSendMailInstanceSendMail() {
+ /**
+ * @return array
+ */
+ public function sendmailModeProvider(): array {
+ return [
+ 'smtp' => ['smtp', ' -bs'],
+ 'pipe' => ['pipe', ' -t'],
+ ];
+ }
+
+ /**
+ * @dataProvider sendmailModeProvider
+ * @param $sendmailMode
+ * @param $binaryParam
+ */
+ public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam) {
$this->config
- ->expects($this->once())
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('mail_smtpmode', 'smtp')
- ->will($this->returnValue('sendmail'));
+ ->will($this->returnValueMap([
+ ['mail_smtpmode', 'smtp', 'sendmail'],
+ ['mail_sendmailmode', 'smtp', $sendmailMode],
+ ]));
$path = \OC_Helper::findBinaryPath('sendmail');
if ($path === null) {
$path = '/usr/sbin/sendmail';
}
- $expected = new \Swift_SendmailTransport($path . ' -bs');
+ $expected = new \Swift_SendmailTransport($path . $binaryParam);
$this->assertEquals($expected, self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
- public function testGetSendMailInstanceSendMailQmail() {
+ /**
+ * @dataProvider sendmailModeProvider
+ * @param $sendmailMode
+ * @param $binaryParam
+ */
+ public function testGetSendmailInstanceSendMailQmail($sendmailMode, $binaryParam) {
$this->config
- ->expects($this->once())
+ ->expects($this->exactly(2))
->method('getSystemValue')
- ->with('mail_smtpmode', 'smtp')
- ->will($this->returnValue('qmail'));
+ ->will($this->returnValueMap([
+ ['mail_smtpmode', 'smtp', 'qmail'],
+ ['mail_sendmailmode', 'smtp', $sendmailMode],
+ ]));
- $this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance'));
+ $this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail' . $binaryParam), self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
public function testGetInstanceDefault() {
@@ -83,8 +107,10 @@ class MailerTest extends TestCase {
public function testGetInstanceSendmail() {
$this->config
->method('getSystemValue')
- ->with('mail_smtpmode', 'smtp')
- ->willReturn('sendmail');
+ ->will($this->returnValueMap([
+ ['mail_smtpmode', 'smtp', 'sendmail'],
+ ['mail_sendmailmode', 'smtp', 'smtp'],
+ ]));
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertInstanceOf(\Swift_Mailer::class, $mailer);
diff --git a/tests/lib/Settings/Admin/MailTest.php b/tests/lib/Settings/Admin/MailTest.php
index 436a7953220..1a1d090418e 100644
--- a/tests/lib/Settings/Admin/MailTest.php
+++ b/tests/lib/Settings/Admin/MailTest.php
@@ -95,6 +95,11 @@ class MailTest extends TestCase {
->method('getSystemValue')
->with('mail_smtppassword', '')
->willReturn('mypassword');
+ $this->config
+ ->expects($this->at(10))
+ ->method('getSystemValue')
+ ->with('mail_sendmailmode', 'smtp')
+ ->willReturn('smtp');
$expected = new TemplateResponse(
'settings',
@@ -111,6 +116,7 @@ class MailTest extends TestCase {
'mail_smtpauth' => true,
'mail_smtpname' => 'smtp.sender.com',
'mail_smtppassword' => '********',
+ 'mail_sendmailmode' => 'smtp',
],
''
);