aboutsummaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/tests
diff options
context:
space:
mode:
authorCyrille Bollu <cyrpub@bollu.be>2022-04-14 21:08:53 +0200
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-06-08 11:29:19 +0000
commit50badb3fb6b6a7fa51520ce380ece09b0a181179 (patch)
tree019251a34dc4732f382f54d5122891a2ad95e54f /apps/sharebymail/tests
parentb7bce42078369fc48df8234fb8e2f110f7b6484d (diff)
downloadnextcloud-server-50badb3fb6b6a7fa51520ce380ece09b0a181179.tar.gz
nextcloud-server-50badb3fb6b6a7fa51520ce380ece09b0a181179.zip
Various improvements related to the recent implementation of temporary passwords
for mail shares: 1- Changes style of "forgot password?" and "Back" button 2- Adds information about share password's expiration time in the emails sent. 3- Shows password expiration time in the Share menu 4- Fixes an issue when the message "Password expires..." would be shown for non email share types (which don't have temporary passswords) 5- At share's creation, password should only be sent when it's a permanent one See also https://github.com/nextcloud/server/issues/31952 Signed-off-by: Cyrille Bollu <cyrpub@bollu.be> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/sharebymail/tests')
-rw-r--r--apps/sharebymail/tests/ShareByMailProviderTest.php35
1 files changed, 15 insertions, 20 deletions
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index b3e344d3ec5..1e5fa46b943 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -252,7 +252,7 @@ class ShareByMailProviderTest extends TestCase {
);
}
- public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtection() {
+ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtectionWithPermanentPassword() {
$share = $this->getMockBuilder(IShare::class)->getMock();
$share->expects($this->any())->method('getSharedWith')->willReturn('receiver@example.com');
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false);
@@ -285,7 +285,7 @@ class ShareByMailProviderTest extends TestCase {
);
}
- public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtectionWithPermanentPassword() {
+ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtectionWithoutPermanentPassword() {
$share = $this->getMockBuilder(IShare::class)->getMock();
$share->expects($this->any())->method('getSharedWith')->willReturn('receiver@example.com');
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false);
@@ -310,21 +310,16 @@ class ShareByMailProviderTest extends TestCase {
// The given password (but not the autogenerated password) should be
// mailed to the receiver of the share because permanent passwords are enforced.
$this->shareManager->expects($this->any())->method('shareApiLinkEnforcePassword')->willReturn(false);
- $this->config->expects($this->once())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(true);
- $this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
$instance->expects($this->never())->method('autoGeneratePassword');
-
- $message = $this->createMock(IMessage::class);
- $message->expects($this->once())->method('setTo')->with(['receiver@example.com']);
- $this->mailer->expects($this->once())->method('createMessage')->willReturn($message);
- $this->mailer->expects($this->once())->method('createEMailTemplate')->with('sharebymail.RecipientPasswordNotification', [
- 'filename' => 'filename',
- 'password' => 'password',
- 'initiator' => 'owner',
- 'initiatorEmail' => null,
- 'shareWith' => 'receiver@example.com',
- ]);
- $this->mailer->expects($this->once())->method('send');
+ $this->config->expects($this->any())->method('getSystemValue')->withConsecutive(
+ ['sharing.enable_mail_link_password_expiration'],
+ ['sharing.enable_mail_link_password_expiration'],
+ ['sharing.mail_link_password_expiration_interval']
+ )->willReturnOnConsecutiveCalls(
+ true,
+ true,
+ 3600
+ );
$this->assertSame('shareObject',
$instance->create($share)
@@ -363,7 +358,7 @@ class ShareByMailProviderTest extends TestCase {
// The autogenerated password should be mailed to the receiver of the share because permanent passwords are enforced.
$this->shareManager->expects($this->any())->method('shareApiLinkEnforcePassword')->willReturn(true);
- $this->config->expects($this->once())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(true);
+ $this->config->expects($this->any())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(false);
$this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
$message = $this->createMock(IMessage::class);
@@ -408,7 +403,7 @@ class ShareByMailProviderTest extends TestCase {
// The given password (but not the autogenerated password) should be
// mailed to the receiver of the share.
$this->shareManager->expects($this->any())->method('shareApiLinkEnforcePassword')->willReturn(true);
- $this->config->expects($this->once())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(true);
+ $this->config->expects($this->any())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(false);
$this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
$instance->expects($this->never())->method('autoGeneratePassword');
@@ -429,7 +424,7 @@ class ShareByMailProviderTest extends TestCase {
);
}
- public function testCreateSendPasswordByTalkWithEnforcedPasswordProtection() {
+ public function testCreateSendPasswordByTalkWithEnforcedPasswordProtectionWithPermanentPassword() {
$share = $this->getMockBuilder(IShare::class)->getMock();
$share->expects($this->any())->method('getSharedWith')->willReturn('receiver@example.com');
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(true);
@@ -453,7 +448,7 @@ class ShareByMailProviderTest extends TestCase {
// The autogenerated password should be mailed to the owner of the share.
$this->shareManager->expects($this->any())->method('shareApiLinkEnforcePassword')->willReturn(true);
- $this->config->expects($this->once())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(false);
+ $this->config->expects($this->any())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(false);
$this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
$instance->expects($this->once())->method('autoGeneratePassword')->with($share)->willReturn('autogeneratedPassword');