aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-06-26 10:23:29 +0200
committerGitHub <noreply@github.com>2023-06-26 10:23:29 +0200
commitf7183c9dcf25ae03b925a90e85f36f21e9159953 (patch)
tree0df0f20d16598d77a8d20da0fe6665bb1cfbf593
parent7d7df35c2e00dd16ba47115c49cccc946189af31 (diff)
parent1cb81ae625f75d0d2a6bf13c9a3b39365dc6d215 (diff)
downloadnextcloud-server-f7183c9dcf25ae03b925a90e85f36f21e9159953.tar.gz
nextcloud-server-f7183c9dcf25ae03b925a90e85f36f21e9159953.zip
Merge pull request #38958 from nextcloud/enh/noid/use-getsystemvalue-mailer
use getsystemvalue-functions in Mailer.php
-rw-r--r--lib/private/Mail/Mailer.php8
-rw-r--r--tests/lib/Mail/MailerTest.php43
2 files changed, 29 insertions, 22 deletions
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 9c38794a5c7..9b7b3cf117b 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -272,7 +272,7 @@ class Mailer implements IMailer {
// either null or true - if nothing is passed, let the symfony mailer figure out the configuration by itself
$mailSmtpsecure = ($this->config->getSystemValue('mail_smtpsecure', null) === 'ssl') ? true : null;
$transport = new EsmtpTransport(
- $this->config->getSystemValue('mail_smtphost', '127.0.0.1'),
+ $this->config->getSystemValueString('mail_smtphost', '127.0.0.1'),
$this->config->getSystemValueInt('mail_smtpport', 25),
$mailSmtpsecure,
null,
@@ -281,11 +281,11 @@ class Mailer implements IMailer {
/** @var SocketStream $stream */
$stream = $transport->getStream();
/** @psalm-suppress InternalMethod */
- $stream->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
+ $stream->setTimeout($this->config->getSystemValueInt('mail_smtptimeout', 10));
if ($this->config->getSystemValueBool('mail_smtpauth', false)) {
- $transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
- $transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
+ $transport->setUsername($this->config->getSystemValueString('mail_smtpname', ''));
+ $transport->setPassword($this->config->getSystemValueString('mail_smtppassword', ''));
}
$streamingOptions = $this->config->getSystemValue('mail_smtpstreamoptions', []);
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index ba1d52f4baf..5ffba939284 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -240,14 +240,17 @@ class MailerTest extends TestCase {
$this->config->method('getSystemValue')
->willReturnMap([
['mail_smtpstreamoptions', [], ['foo' => 1]],
- ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
- ['mail_smtpport', 25, 25],
- ['mail_smtptimeout', 10, 10],
]);
$this->config->method('getSystemValueString')
->willReturnMap([
['mail_smtpmode', 'smtp', 'smtp'],
['overwrite.cli.url', '', ''],
+ ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
+ ]);
+ $this->config->method('getSystemValueInt')
+ ->willReturnMap([
+ ['mail_smtpport', 25, 25],
+ ['mail_smtptimeout', 10, 10],
]);
$mailer = self::invokePrivate($this->mailer, 'getInstance');
/** @var EsmtpTransport $transport */
@@ -261,15 +264,19 @@ class MailerTest extends TestCase {
$this->config->method('getSystemValue')
->willReturnMap([
['mail_smtpstreamoptions', [], 'bar'],
- ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
- ['mail_smtpport', 25, 25],
- ['mail_smtptimeout', 10, 10],
]);
$this->config->method('getSystemValueString')
->willReturnMap([
['mail_smtpmode', 'smtp', 'smtp'],
['overwrite.cli.url', '', ''],
+ ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
+ ]);
+ $this->config->method('getSystemValueInt')
+ ->willReturnMap([
+ ['mail_smtpport', 25, 25],
+ ['mail_smtptimeout', 10, 10],
]);
+
$mailer = self::invokePrivate($this->mailer, 'getInstance');
/** @var EsmtpTransport $transport */
$transport = self::invokePrivate($mailer, 'transport');
@@ -278,16 +285,16 @@ class MailerTest extends TestCase {
}
public function testLocalDomain(): void {
- $this->config->method('getSystemValue')
- ->willReturnMap([
- ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
- ['mail_smtpport', 25, 25],
- ['mail_smtptimeout', 10, 10],
- ]);
$this->config->method('getSystemValueString')
->willReturnMap([
['mail_smtpmode', 'smtp', 'smtp'],
['overwrite.cli.url', '', 'https://some.valid.url.com:8080'],
+ ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
+ ]);
+ $this->config->method('getSystemValueInt')
+ ->willReturnMap([
+ ['mail_smtpport', 25, 25],
+ ['mail_smtptimeout', 10, 10],
]);
/** @var SymfonyMailer $mailer */
@@ -301,16 +308,16 @@ class MailerTest extends TestCase {
}
public function testLocalDomainInvalidUrl(): void {
- $this->config->method('getSystemValue')
- ->willReturnMap([
- ['mail_smtpport', 25, 25],
- ['mail_smtptimeout', 10, 10],
- ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
- ]);
$this->config->method('getSystemValueString')
->willReturnMap([
['mail_smtpmode', 'smtp', 'smtp'],
['overwrite.cli.url', '', 'https:only.slash.does.not.work:8080'],
+ ['mail_smtphost', '127.0.0.1', '127.0.0.1'],
+ ]);
+ $this->config->method('getSystemValueInt')
+ ->willReturnMap([
+ ['mail_smtpport', 25, 25],
+ ['mail_smtptimeout', 10, 10],
]);
/** @var SymfonyMailer $mailer */