From 3cac7911d592260fd48a489ee07bf4cb3b500dd9 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Sat, 17 Mar 2018 01:11:30 +0000 Subject: [tx-robot] updated from transifex --- apps/federatedfilesharing/l10n/nl.js | 1 + apps/federatedfilesharing/l10n/nl.json | 1 + 2 files changed, 2 insertions(+) (limited to 'apps/federatedfilesharing/l10n') diff --git a/apps/federatedfilesharing/l10n/nl.js b/apps/federatedfilesharing/l10n/nl.js index ef12bf97e7a..2f536035cf1 100644 --- a/apps/federatedfilesharing/l10n/nl.js +++ b/apps/federatedfilesharing/l10n/nl.js @@ -17,6 +17,7 @@ OC.L10N.register( "Couldn't establish a federated share." : "Kon geen gefedereerde share tot stand brengen", "Couldn't establish a federated share, maybe the password was wrong." : "Kon geen gefedereerde share tot stand brengen, misschien was het wachtwoord onjuist.", "Federated Share request sent, you will receive an invitation. Check your notifications." : "De gefedereerde share aanvraag is verzonden, je ontvangt een uitnodiging. Controleer je meldingen.", + "Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)." : "Kon geen gefedereerde share tot stand brengen, waarschijnlijk was de federatieserver te oud (Nextcloud <=9).", "Sharing %s failed, because this item is already shared with %s" : "Delen van %s is mislukt, omdat het object al wordt gedeeld met %s", "Not allowed to create a federated share with the same user" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "File is already shared with %s" : "Bestand is al gedeeld met %s", diff --git a/apps/federatedfilesharing/l10n/nl.json b/apps/federatedfilesharing/l10n/nl.json index 2be75acc143..328087c4ece 100644 --- a/apps/federatedfilesharing/l10n/nl.json +++ b/apps/federatedfilesharing/l10n/nl.json @@ -15,6 +15,7 @@ "Couldn't establish a federated share." : "Kon geen gefedereerde share tot stand brengen", "Couldn't establish a federated share, maybe the password was wrong." : "Kon geen gefedereerde share tot stand brengen, misschien was het wachtwoord onjuist.", "Federated Share request sent, you will receive an invitation. Check your notifications." : "De gefedereerde share aanvraag is verzonden, je ontvangt een uitnodiging. Controleer je meldingen.", + "Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)." : "Kon geen gefedereerde share tot stand brengen, waarschijnlijk was de federatieserver te oud (Nextcloud <=9).", "Sharing %s failed, because this item is already shared with %s" : "Delen van %s is mislukt, omdat het object al wordt gedeeld met %s", "Not allowed to create a federated share with the same user" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "File is already shared with %s" : "Bestand is al gedeeld met %s", -- cgit v1.2.3 ='artonge/chore/update_nc_pwd_confirmation_v5.3.1'>artonge/chore/update_nc_pwd_confirmation_v5.3.1 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/settings/tests/Controller/MailSettingsControllerTest.php
blob: 331e6283544c1a2e148a9ce55b78ddeac8f172b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/**
 * @copyright 2014 Lukas Reschke lukas@nextcloud.com
 * @copyright Copyright (c) 2017  Joas Schilling <coding@schilljs.com>
 *
 * @author Christoph Wurst <christoph@winzerhof-wurst.at>
 * @author Daniel Kesselberg <mail@danielkesselberg.de>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Lukas Reschke <lukas@statuscode.ch>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * 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
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace OCA\Settings\Tests\Controller;

use OC\Mail\Message;
use OC\User\User;
use OCA\Settings\Controller\MailSettingsController;
use OCP\AppFramework\Http;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;

/**
 * @package Tests\Settings\Controller
 */
class MailSettingsControllerTest extends \Test\TestCase {

	/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
	private $config;
	/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
	private $userSession;
	/** @var IMailer|\PHPUnit_Framework_MockObject_MockObject */
	private $mailer;
	/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
	private $l;

	/** @var MailSettingsController */
	private $mailController;

	protected function setUp(): void {
		parent::setUp();

		$this->l = $this->createMock(IL10N::class);
		$this->config = $this->createMock(IConfig::class);
		$this->userSession = $this->createMock(IUserSession::class);
		$this->mailer = $this->createMock(IMailer::class);
		/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject $request */
		$request = $this->createMock(IRequest::class);
		$this->mailController = new MailSettingsController(
			'settings',
			$request,
			$this->l,
			$this->config,
			$this->userSession,
			$this->mailer,
			'no-reply@nextcloud.com'
		);
	}

	public function testSetMailSettings() {
		$this->config->expects($this->exactly(2))
			->method('setSystemValues')
			->withConsecutive(
				[[
					'mail_domain' => 'nextcloud.com',
					'mail_from_address' => 'demo@nextcloud.com',
					'mail_smtpmode' => 'smtp',
					'mail_smtpsecure' => 'ssl',
					'mail_smtphost' => 'mx.nextcloud.org',
					'mail_smtpauthtype' => 'NTLM',
					'mail_smtpauth' => 1,
					'mail_smtpport' => '25',
					'mail_sendmailmode' => null,
				]],
				[[
					'mail_domain' => 'nextcloud.com',
					'mail_from_address' => 'demo@nextcloud.com',
					'mail_smtpmode' => 'smtp',
					'mail_smtpsecure' => 'ssl',
					'mail_smtphost' => 'mx.nextcloud.org',
					'mail_smtpauthtype' => 'NTLM',
					'mail_smtpauth' => null,
					'mail_smtpport' => '25',
					'mail_smtpname' => null,
					'mail_smtppassword' => null,
					'mail_sendmailmode' => null,
				]]
			);

		// With authentication
		$response = $this->mailController->setMailSettings(
			'nextcloud.com',
			'demo@nextcloud.com',
			'smtp',
			'ssl',
			'mx.nextcloud.org',
			'NTLM',
			1,
			'25',
			null
		);
		$this->assertSame(Http::STATUS_OK, $response->getStatus());

		// Without authentication (testing the deletion of the stored password)
		$response = $this->mailController->setMailSettings(
			'nextcloud.com',
			'demo@nextcloud.com',
			'smtp',
			'ssl',
			'mx.nextcloud.org',
			'NTLM',
			0,
			'25',
			null
		);
		$this->assertSame(Http::STATUS_OK, $response->getStatus());

	}

	public function testStoreCredentials() {
		$this->config
			->expects($this->once())
			->method('setSystemValues')
			->with([
				'mail_smtpname' => 'UsernameToStore',
				'mail_smtppassword' => 'PasswordToStore',
			]);

		$response = $this->mailController->storeCredentials('UsernameToStore', 'PasswordToStore');
		$this->assertSame(Http::STATUS_OK, $response->getStatus());
	}

	public function testSendTestMail() {
		$user = $this->createMock(User::class);
		$user->expects($this->any())
			->method('getUID')
			->will($this->returnValue('Werner'));
		$user->expects($this->any())
			->method('getDisplayName')
			->will($this->returnValue('Werner Brösel'));

		$this->l->expects($this->any())
			->method('t')
			->willReturnCallback(function($text, $parameters = []) {
				return vsprintf($text, $parameters);
			});
		$this->userSession
			->expects($this->any())
			->method('getUser')
			->will($this->returnValue($user));

		// Ensure that it fails when no mail address has been specified
		$response = $this->mailController->sendTestMail();
		$this->assertSame(Http::STATUS_BAD_REQUEST, $response->getStatus());
		$this->assertSame('You need to set your user email before being able to send test emails.', $response->getData());

		// If no exception is thrown it should work
		$this->config
			->expects($this->any())
			->method('getUserValue')
			->will($this->returnValue('mail@example.invalid'));
		$this->mailer->expects($this->once())
			->method('createMessage')
			->willReturn($this->createMock(Message::class));
		$emailTemplate = $this->createMock(IEMailTemplate::class);
		$this->mailer
			->expects($this->once())
			->method('createEMailTemplate')
			->willReturn($emailTemplate);
		$response = $this->mailController->sendTestMail();
		$this->assertSame(Http::STATUS_OK, $response->getStatus());
	}

}