Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-05-31 15:43:14 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2021-05-31 16:04:00 +0300
commit747325fc435cd0d295ba495507facd0bc145d086 (patch)
tree4355df8b0c0476cdf573a14f9a85a2b8f9aecdcd /tests/lib/Mail
parent719430559f1a1f28800a9a26d4a5492aae046730 (diff)
Set local domain for swiftmailer transport
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests/lib/Mail')
-rw-r--r--tests/lib/Mail/MailerTest.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index a11a1ab0914..335f373f8c1 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -22,8 +22,8 @@ use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Mail\Events\BeforeMessageSent;
-use Test\TestCase;
use Swift_SwiftException;
+use Test\TestCase;
class MailerTest extends TestCase {
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
@@ -218,4 +218,42 @@ class MailerTest extends TestCase {
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertEquals(0, count($mailer->getTransport()->getStreamOptions()));
}
+
+ public function testLocalDomain(): void {
+ $this->config->method('getSystemValue')
+ ->willReturnMap([
+ ['mail_smtpmode', 'smtp', 'smtp']
+ ]);
+ $this->config->method('getSystemValueString')
+ ->with('overwrite.cli.url', '')
+ ->willReturn('https://some.valid.url.com:8080');
+
+ /** @var \Swift_Mailer $mailer */
+ $mailer = self::invokePrivate($this->mailer, 'getInstance');
+ self::assertInstanceOf(\Swift_Mailer::class, $mailer);
+
+ /** @var \Swift_Transport_EsmtpTransport $transport */
+ $transport = $mailer->getTransport();
+ self::assertInstanceOf(\Swift_Transport_EsmtpTransport::class, $transport);
+ self::assertEquals('some.valid.url.com', $transport->getLocalDomain());
+ }
+
+ public function testLocalDomainInvalidUrl(): void {
+ $this->config->method('getSystemValue')
+ ->willReturnMap([
+ ['mail_smtpmode', 'smtp', 'smtp']
+ ]);
+ $this->config->method('getSystemValueString')
+ ->with('overwrite.cli.url', '')
+ ->willReturn('https:only.slash.does.not.work:8080');
+
+ /** @var \Swift_Mailer $mailer */
+ $mailer = self::invokePrivate($this->mailer, 'getInstance');
+ self::assertInstanceOf(\Swift_Mailer::class, $mailer);
+
+ /** @var \Swift_Transport_EsmtpTransport $transport */
+ $transport = $mailer->getTransport();
+ self::assertInstanceOf(\Swift_Transport_EsmtpTransport::class, $transport);
+ self::assertEquals('[127.0.0.1]', $transport->getLocalDomain());
+ }
}