diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2021-01-27 18:54:37 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-02-26 18:36:46 +0300 |
commit | 82ab9d00075bf00d611e819ef9c3a6cc72c12c26 (patch) | |
tree | d59f99e49ebfe0be9c389ae8aee7311c3d9040d8 /tests | |
parent | 685580fff2859112bc1dd37b3823f0ada0950811 (diff) |
Add Sieve support
* Expose managesieve port
* Add sieve client factory
* Add support for sieve to provisioning
* Refactor test connectivity logic and add sieve.
* Add support for sieve to provisioning
* Add sieve to account form
* Add debug logger for ManageSieve
* Add api to get and update active script
* Add error for managesieve exception
* Add text editor to update existing script
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Integration/Db/MailAccountTest.php | 2 | ||||
-rw-r--r-- | tests/Integration/Sieve/SieveClientFactoryTest.php | 117 | ||||
-rw-r--r-- | tests/Integration/Sieve/SieveLoggerTest.php | 46 | ||||
-rw-r--r-- | tests/Unit/Controller/SettingsControllerTest.php | 14 | ||||
-rw-r--r-- | tests/Unit/Controller/SieveControllerTest.php | 166 | ||||
-rw-r--r-- | tests/Unit/Migration/AddSieveToProvisioningConfigTest.php | 121 | ||||
-rw-r--r-- | tests/Unit/Service/Provisioning/ConfigTest.php | 110 | ||||
-rw-r--r-- | tests/Unit/Service/Provisioning/ManagerTest.php | 5 | ||||
-rw-r--r-- | tests/Unit/Service/Provisioning/TestConfig.php | 5 | ||||
-rw-r--r-- | tests/Unit/Service/SetupServiceTest.php | 6 |
10 files changed, 547 insertions, 45 deletions
diff --git a/tests/Integration/Db/MailAccountTest.php b/tests/Integration/Db/MailAccountTest.php index 8bf2af949..fd2ad11e3 100644 --- a/tests/Integration/Db/MailAccountTest.php +++ b/tests/Integration/Db/MailAccountTest.php @@ -69,6 +69,7 @@ class MailAccountTest extends TestCase { 'draftsMailboxId' => null, 'sentMailboxId' => null, 'trashMailboxId' => null, + 'sieveEnabled' => false, ], $a->toJson()); } @@ -95,6 +96,7 @@ class MailAccountTest extends TestCase { 'draftsMailboxId' => null, 'sentMailboxId' => null, 'trashMailboxId' => null, + 'sieveEnabled' => false, ]; $a = new MailAccount($expected); // TODO: fix inconsistency diff --git a/tests/Integration/Sieve/SieveClientFactoryTest.php b/tests/Integration/Sieve/SieveClientFactoryTest.php new file mode 100644 index 000000000..47964c32c --- /dev/null +++ b/tests/Integration/Sieve/SieveClientFactoryTest.php @@ -0,0 +1,117 @@ +<?php + +declare(strict_types=1); + +/** + * @author Daniel Kesselberg <mail@danielkesselberg.de> + * + * Mail + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Mail\Tests\Integration\Sieve; + +use ChristophWurst\Nextcloud\Testing\TestCase; +use Horde\ManageSieve; +use OC; +use OCA\Mail\Account; +use OCA\Mail\Db\MailAccount; +use OCA\Mail\Sieve\SieveClientFactory; +use OCP\IConfig; +use OCP\Security\ICrypto; +use PHPUnit\Framework\MockObject\MockObject; + +class SieveClientFactoryTest extends TestCase { + + /** @var ICrypto|MockObject */ + private $crypto; + + /** @var IConfig|MockObject */ + private $config; + + /** @var SieveClientFactory */ + private $factory; + + protected function setUp(): void { + parent::setUp(); + + $this->crypto = $this->createMock(ICrypto::class); + $this->config = $this->createMock(IConfig::class); + + $this->config->method('getSystemValue') + ->willReturnCallback(static function ($key, $default) { + if ($key === 'app.mail.sieve.timeout') { + return 5; + } + if ($key === 'debug') { + return false; + } + return null; + }); + + $this->config->method('getSystemValueBool') + ->with('app.mail.verify-tls-peer', true) + ->willReturn(false); + + $this->factory = new SieveClientFactory($this->crypto, $this->config); + } + + /** + * @return Account + */ + private function getTestAccount() { + $mailAccount = new MailAccount(); + $mailAccount->setId(123); + $mailAccount->setEmail('user@domain.tld'); + $mailAccount->setInboundHost('127.0.0.1'); + $mailAccount->setInboundPort(993); + $mailAccount->setInboundSslMode('ssl'); + $mailAccount->setInboundUser('user@domain.tld'); + $mailAccount->setInboundPassword(OC::$server->get(ICrypto::class)->encrypt('mypassword')); + $mailAccount->setSieveHost('127.0.0.1'); + $mailAccount->setSievePort(4190); + $mailAccount->setSieveSslMode(''); + $mailAccount->setSieveUser(''); + $mailAccount->setSievePassword(''); + return new Account($mailAccount); + } + + public function testClientConnectivity() { + $account = $this->getTestAccount(); + $this->crypto->expects($this->once()) + ->method('decrypt') + ->with($account->getMailAccount()->getInboundPassword()) + ->willReturn('mypassword'); + + $client = $this->factory->getClient($account); + $this->assertInstanceOf(ManageSieve::class, $client); + } + + public function testClientInstallScript() { + $account = $this->getTestAccount(); + $this->crypto->expects($this->once()) + ->method('decrypt') + ->with($account->getMailAccount()->getInboundPassword()) + ->willReturn('mypassword'); + + $client = $this->factory->getClient($account); + + $client->installScript('test', '#test'); + $this->assertCount(1, $client->listScripts()); + + $client->removeScript('test'); + $this->assertCount(0, $client->listScripts()); + } +} diff --git a/tests/Integration/Sieve/SieveLoggerTest.php b/tests/Integration/Sieve/SieveLoggerTest.php new file mode 100644 index 000000000..fbb526a76 --- /dev/null +++ b/tests/Integration/Sieve/SieveLoggerTest.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +/** + * @author Daniel Kesselberg <mail@danielkesselberg.de> + * + * Mail + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Mail\Tests\Integration\Sieve; + +use ChristophWurst\Nextcloud\Testing\TestCase; +use OCA\Mail\Sieve\SieveLogger; + +class SieveLoggerTest extends TestCase { + public function testOpenInvalidFile(): void { + $this->expectException(\InvalidArgumentException::class); + $this->expectDeprecationMessage('Unable to use "/root/horde_sieve.log" as log file for sieve.'); + new SieveLogger('/root/horde_sieve.log'); + } + + public function testWriteLog(): void { + $logFile = sys_get_temp_dir() . '/horde_sieve.log'; + @unlink($logFile); + + $logger = new SieveLogger($logFile); + $logger->debug('Test'); + unset($logger); + + $this->assertStringEqualsFile($logFile, 'Test'); + } +} diff --git a/tests/Unit/Controller/SettingsControllerTest.php b/tests/Unit/Controller/SettingsControllerTest.php index 0c97f60f7..c19b459ca 100644 --- a/tests/Unit/Controller/SettingsControllerTest.php +++ b/tests/Unit/Controller/SettingsControllerTest.php @@ -58,7 +58,12 @@ class SettingsControllerTest extends TestCase { '%USERID%@domain.com', 'mx.domain.com', 567, - 'tls' + 'tls', + false, + '', + '', + 0, + '' ); $response = $this->controller->provisioning( @@ -70,7 +75,12 @@ class SettingsControllerTest extends TestCase { '%USERID%@domain.com', 'mx.domain.com', 567, - 'tls' + 'tls', + false, + '', + '', + 0, + '' ); $this->assertInstanceOf(JSONResponse::class, $response); diff --git a/tests/Unit/Controller/SieveControllerTest.php b/tests/Unit/Controller/SieveControllerTest.php new file mode 100644 index 000000000..2d80afcbb --- /dev/null +++ b/tests/Unit/Controller/SieveControllerTest.php @@ -0,0 +1,166 @@ +<?php + +declare(strict_types=1); + +/** + * @author Daniel Kesselberg <mail@danielkesselberg.de> + * + * Mail + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Mail\Tests\Unit\Controller; + +use ChristophWurst\Nextcloud\Testing\ServiceMockObject; +use Horde\ManageSieve\Exception; +use OCA\Mail\Account; +use OCA\Mail\Controller\SieveController; +use OCA\Mail\Db\MailAccount; +use OCA\Mail\Exception\CouldNotConnectException; +use OCA\Mail\Tests\Integration\TestCase; + +class SieveControllerTest extends TestCase { + + /** @var ServiceMockObject */ + private $serviceMock; + + /** @var SieveController */ + private $sieveController; + + + protected function setUp(): void { + parent::setUp(); + $this->serviceMock = $this->createServiceMock( + SieveController::class, + ['UserId' => '1'] + ); + $this->sieveController = $this->serviceMock->getService(); + } + + public function testUpdateAccountDisable(): void { + $mailAccountMapper = $this->serviceMock->getParameter('mailAccountMapper'); + $mailAccountMapper->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new MailAccount()); + $mailAccountMapper->expects($this->once()) + ->method('save'); + + $response = $this->sieveController->updateAccount(2, false, '', 0, '', '', ''); + $this->assertEquals(false, $response->getData()['sieveEnabled']); + } + + public function testUpdateAccountEnable(): void { + $mailAccountMapper = $this->serviceMock->getParameter('mailAccountMapper'); + $mailAccountMapper->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new MailAccount()); + $mailAccountMapper->expects($this->once()) + ->method('save'); + + $response = $this->sieveController->updateAccount(2, true, 'localhost', 4190, 'user', 'password', ''); + $this->assertEquals(true, $response->getData()['sieveEnabled']); + } + + public function testUpdateAccountEnableImapCredentials(): void { + $mailAccount = new MailAccount(); + $mailAccount->setInboundUser('imap_user'); + $mailAccount->setInboundPassword('imap_password'); + + $mailAccountMapper = $this->serviceMock->getParameter('mailAccountMapper'); + $mailAccountMapper->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn($mailAccount); + $mailAccountMapper->expects($this->once()) + ->method('save'); + + $response = $this->sieveController->updateAccount(2, true, 'localhost', 4190, '', '', ''); + $this->assertEquals(true, $response->getData()['sieveEnabled']); + } + + public function testUpdateAccountEnableNoConnection(): void { + $this->expectException(CouldNotConnectException::class); + $this->expectExceptionMessage('Connection to ManageSieve at localhost:4190 failed. Computer says no'); + + $mailAccountMapper = $this->serviceMock->getParameter('mailAccountMapper'); + $mailAccountMapper->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new MailAccount()); + + $sieveClientFactory = $this->serviceMock->getParameter('sieveClientFactory'); + $sieveClientFactory->expects($this->once()) + ->method('createClient') + ->willThrowException(new Exception('Computer says no')); + + $this->sieveController->updateAccount(2, true, 'localhost', 4190, 'user', 'password', ''); + } + + public function testGetActiveScript(): void { + $mailAccount = new MailAccount(); + $mailAccount->setSieveEnabled(true); + $mailAccount->setSieveHost('localhost'); + $mailAccount->setSievePort(4190); + $mailAccount->setSieveUser('user'); + $mailAccount->setSievePassword('password'); + $mailAccount->setSieveSslMode(''); + + $accountService = $this->serviceMock->getParameter('accountService'); + $accountService->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new Account($mailAccount)); + + $response = $this->sieveController->getActiveScript(2); + $this->assertEquals(['scriptName' => '', 'script' => ''], $response->getData()); + } + + public function testGetActiveScriptNoSieve(): void { + $this->expectException(CouldNotConnectException::class); + $this->expectExceptionMessage('ManageSieve is disabled'); + + $mailAccount = new MailAccount(); + $mailAccount->setSieveEnabled(false); + + $accountService = $this->serviceMock->getParameter('accountService'); + $accountService->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new Account($mailAccount)); + + $this->sieveController->getActiveScript(2); + } + + public function testUpdateActiveScript(): void { + $mailAccount = new MailAccount(); + $mailAccount->setSieveEnabled(true); + $mailAccount->setSieveHost('localhost'); + $mailAccount->setSievePort(4190); + $mailAccount->setSieveUser('user'); + $mailAccount->setSievePassword('password'); + $mailAccount->setSieveSslMode(''); + + $accountService = $this->serviceMock->getParameter('accountService'); + $accountService->expects($this->once()) + ->method('find') + ->with('1', 2) + ->willReturn(new Account($mailAccount)); + + $response = $this->sieveController->updateActiveScript(2, 'sieve script'); + $this->assertEquals([], $response->getData()); + } +} diff --git a/tests/Unit/Migration/AddSieveToProvisioningConfigTest.php b/tests/Unit/Migration/AddSieveToProvisioningConfigTest.php new file mode 100644 index 000000000..a8ddcec3c --- /dev/null +++ b/tests/Unit/Migration/AddSieveToProvisioningConfigTest.php @@ -0,0 +1,121 @@ +<?php + +declare(strict_types=1); + +/** + * @author Daniel Kesselberg <mail@danielkesselberg.de> + * + * Mail + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Mail\Tests\Unit\Migration; + +use ChristophWurst\Nextcloud\Testing\ServiceMockObject; +use ChristophWurst\Nextcloud\Testing\TestCase; +use OCA\Mail\Migration\AddSieveToProvisioningConfig; +use OCA\Mail\Service\Provisioning\Config; +use OCP\Migration\IOutput; +use PHPUnit\Framework\MockObject\MockObject; + +class AddSieveToProvisioningConfigTest extends TestCase { + + /** @var ServiceMockObject */ + private $mock; + + /** @var AddSieveToProvisioningConfig */ + private $repairStep; + + protected function setUp(): void { + parent::setUp(); + + $this->mock = $this->createServiceMock(AddSieveToProvisioningConfig::class); + $this->repairStep = $this->mock->getService(); + } + + + public function testRunNoConfigToMigrate() { + $this->mock->getParameter('config') + ->expects($this->once()) + ->method('getAppValue') + ->with('mail', 'installed_version') + ->willReturn('1.8.0'); + + /** @var IOutput|MockObject $output */ + $output = $this->createMock(IOutput::class); + $output->expects($this->never()) + ->method('info'); + + $this->repairStep->run($output); + } + + public function testRun() { + $this->mock->getParameter('config') + ->expects($this->once()) + ->method('getAppValue') + ->with('mail', 'installed_version') + ->willReturn('1.8.0'); + + $this->mock->getParameter('configMapper') + ->expects($this->once()) + ->method('load') + ->willReturn(new Config([ + 'email' => '%USERID%@domain.com', + 'imapUser' => '%USERID%@domain.com', + 'imapHost' => 'mx.domain.com', + 'imapPort' => 993, + 'imapSslMode' => 'ssl', + 'smtpUser' => '%USERID%@domain.com', + 'smtpHost' => 'mx.domain.com', + 'smtpPort' => 567, + 'smtpSslMode' => 'tls', + ])); + + $this->mock->getParameter('configMapper') + ->expects($this->once()) + ->method('save') + ->with(new Config([ + 'email' => '%USERID%@domain.com', + 'imapUser' => '%USERID%@domain.com', + 'imapHost' => 'mx.domain.com', + 'imapPort' => 993, + 'imapSslMode' => 'ssl', + 'smtpUser' => '%USERID%@domain.com', + 'smtpHost' => 'mx.domain.com', + 'smtpPort' => 567, + 'smtpSslMode' => 'tls', + 'sieveEnabled' => false, + 'sieveHost' => '', + 'sievePort' => 4190, + 'sieveUser' => '', + 'sieveSslMode' => 'tls', + ])); + + /** @var IOutput|MockObject $output */ + $output = $this->createMock(IOutput::class); + $output->expects($this->once()) + ->method('info') + ->with('added sieve defaults to provisioning config'); + + $this->repairStep->run($output); + } + + public function testGetName() { + $this->assertEquals( + 'Add sieve defaults to provisioning config', + $this->repairStep->getName() + ); + } +} diff --git a/tests/Unit/Service/Provisioning/ConfigTest.php b/tests/Unit/Service/Provisioning/ConfigTest.php index b5222be64..839bfcb76 100644 --- a/tests/Unit/Service/Provisioning/ConfigTest.php +++ b/tests/Unit/Service/Provisioning/ConfigTest.php @@ -56,30 +56,6 @@ class ConfigTest extends TestCase { $this->assertEquals('user@domain.se', $config->buildEmail($user)); } - public function testGetImapHost() { - $config = new Config([ - 'imapHost' => 'imap.domain.com', - ]); - - $this->assertEquals('imap.domain.com', $config->getImapHost()); - } - - public function testGetImapPort() { - $config = new Config([ - 'imapPort' => 993, - ]); - - $this->assertEquals(993, $config->getImapPort()); - } - - public function testGetImapSslMode() { - $config = new Config([ - 'imapSslMode' => 'ssl', - ]); - - $this->assertEquals('ssl', $config->getImapSslMode()); - } - public function testBuildImapUserWithUserId() { $user = $this->createMock(IUser::class); $config = new Config([ @@ -125,34 +101,55 @@ class ConfigTest extends TestCase { $this->assertEquals('user@domain.se', $config->buildImapUser($user)); } - public function testGetSmtpSslMode() { + public function testBuildSmtpUserWithUserId() { + $user = $this->createMock(IUser::class); $config = new Config([ - 'smtpSslMode' => 'tls', + 'smtpUser' => '%USERID%@domain.se', ]); + $user->expects($this->exactly(2)) + ->method('getUID') + ->willReturn('test'); + $user->expects($this->once()) + ->method('getEMailAddress') + ->willReturn(null); - $this->assertEquals('tls', $config->getSmtpSslMode()); + $this->assertEquals('test@domain.se', $config->buildSmtpUser($user)); } - public function testGetSmtpHost() { + public function testBuilldSmtpUserWithEmailPlaceholder() { + $user = $this->createMock(IUser::class); $config = new Config([ - 'smtpHost' => 'smtp.domain.com', + 'smtpUser' => '%EMAIL%', ]); + $user->expects($this->any()) + ->method('getUID') + ->willReturn(null); + $user->expects($this->any()) + ->method('getEMailAddress') + ->willReturn('user@domain.se'); - $this->assertEquals('smtp.domain.com', $config->getSmtpHost()); + $this->assertEquals('user@domain.se', $config->buildSmtpUser($user)); } - public function testGetSmtpPort() { + public function testBuildSmtpUserFromDefaultEmail() { + $user = $this->createMock(IUser::class); $config = new Config([ - 'smtpPort' => 465, + 'email' => '%EMAIL%', ]); + $user->expects($this->exactly(2)) + ->method('getUID') + ->willReturn('user'); + $user->expects($this->exactly(2)) + ->method('getEMailAddress') + ->willReturn('user@domain.se'); - $this->assertEquals(465, $config->getSmtpPort()); + $this->assertEquals('user@domain.se', $config->buildImapUser($user)); } - public function testBuildSmtpUserWithUserId() { + public function testBuildSieveUserWithUserId(): void { $user = $this->createMock(IUser::class); $config = new Config([ - 'smtpUser' => '%USERID%@domain.se', + 'sieveUser' => '%USERID%@domain.se', ]); $user->expects($this->exactly(2)) ->method('getUID') @@ -161,25 +158,25 @@ class ConfigTest extends TestCase { ->method('getEMailAddress') ->willReturn(null); - $this->assertEquals('test@domain.se', $config->buildSmtpUser($user)); + $this->assertEquals('test@domain.se', $config->buildSieveUser($user)); } - public function testBuilldSmtpUserWithEmailPlaceholder() { + public function testBuilldSieveUserWithEmailPlaceholder(): void { $user = $this->createMock(IUser::class); $config = new Config([ - 'smtpUser' => '%EMAIL%', + 'sieveUser' => '%EMAIL%', ]); - $user->expects($this->any()) + $user->expects($this->once()) ->method('getUID') ->willReturn(null); - $user->expects($this->any()) + $user->expects($this->exactly(2)) ->method('getEMailAddress') ->willReturn('user@domain.se'); - $this->assertEquals('user@domain.se', $config->buildSmtpUser($user)); + $this->assertEquals('user@domain.se', $config->buildSieveUser($user)); } - public function testBuildSmtpUserFromDefaultEmail() { + public function testBuildSieveUserFromDefaultEmail(): void { $user = $this->createMock(IUser::class); $config = new Config([ 'email' => '%EMAIL%', @@ -191,6 +188,33 @@ class ConfigTest extends TestCase { ->method('getEMailAddress') ->willReturn('user@domain.se'); - $this->assertEquals('user@domain.se', $config->buildImapUser($user)); + $this->assertEquals('user@domain.se', $config->buildSieveUser($user)); + } + + /** + * @param string $key + * @param mixed $value + * @dataProvider providerTestGetter + */ + public function testGetter(string $key, $value): void { + $config = new Config([ + $key => $value + ]); + $this->assertEquals($value, $config->{'get' . ucfirst($key)}()); + } + + public function providerTestGetter(): array { + return [ + 'smtpHost' => ['smtpHost', 'smtp.domain.com'], + 'smtpPort' => ['smtpPort', 465], + 'smtpSslMode' => ['smtpSslMode', 'tls'], + 'imapHost' => ['imapHost', 'imap.domain.com'], + 'imapPort' => ['imapPort', 993], + 'imapSslMode' => ['imapSslMode', 'tls'], + 'sieveEnabled' => ['sieveEnabled', true], + 'sieveHost' => ['sieveHost', 'imap.domain.com'], + 'sievePort' => ['sieveHost', 4190], + 'sieveSslMode' => ['sieveSslMode', 'tls'], + ]; } } diff --git a/tests/Unit/Service/Provisioning/ManagerTest.php b/tests/Unit/Service/Provisioning/ManagerTest.php index 66b0accfc..81b0ede1e 100644 --- a/tests/Unit/Service/Provisioning/ManagerTest.php +++ b/tests/Unit/Service/Provisioning/ManagerTest.php @@ -178,6 +178,11 @@ class ManagerTest extends TestCase { '%USERID%@domain.com', 'mx.domain.com', 567, + 'tls', + false, + '', + '', + 0, 'tls' ); } diff --git a/tests/Unit/Service/Provisioning/TestConfig.php b/tests/Unit/Service/Provisioning/TestConfig.php index 26cf72bdc..9ebf3157a 100644 --- a/tests/Unit/Service/Provisioning/TestConfig.php +++ b/tests/Unit/Service/Provisioning/TestConfig.php @@ -39,6 +39,11 @@ class TestConfig extends Config { 'smtpHost' => 'mx.domain.com', 'smtpPort' => 567, 'smtpSslMode' => 'tls', + 'sieveEnabled' => false, + 'sieveHost' => '', + 'sievePort' => 4190, + 'sieveUser' => '', + 'sieveSslMode' => 'tls', ]); } } diff --git a/tests/Unit/Service/SetupServiceTest.php b/tests/Unit/Service/SetupServiceTest.php index 0bf424a57..70288db2a 100644 --- a/tests/Unit/Service/SetupServiceTest.php +++ b/tests/Unit/Service/SetupServiceTest.php @@ -28,6 +28,7 @@ namespace OCA\Mail\Tests\Unit\Service; use OCA\Mail\Account; use OCA\Mail\Db\MailAccount; +use OCA\Mail\IMAP\IMAPClientFactory; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\AutoConfig\AutoConfig; use OCA\Mail\Service\SetupService; @@ -51,6 +52,9 @@ class SetupServiceTest extends TestCase { /** @var SmtpClientFactory|MockObject */ private $smtpClientFactory; + /** @var IMAPClientFactory|MockObject */ + private $imapClientFactory; + /** @var LoggerInterface|MockObject */ private $logger; @@ -64,6 +68,7 @@ class SetupServiceTest extends TestCase { $this->accountService = $this->createMock(AccountService::class); $this->crypto = $this->createMock(ICrypto::class); $this->smtpClientFactory = $this->createMock(SmtpClientFactory::class); + $this->imapClientFactory = $this->createMock(IMAPClientFactory::class); $this->logger = $this->createMock(LoggerInterface::class); $this->service = new SetupService( @@ -71,6 +76,7 @@ class SetupServiceTest extends TestCase { $this->accountService, $this->crypto, $this->smtpClientFactory, + $this->imapClientFactory, $this->logger ); } |