@@ -484,7 +484,7 @@ public function testGetExpiredShareById() {
484484
485485 public function testVerifyPasswordNullButEnforced () {
486486 $ this ->expectException (\InvalidArgumentException::class);
487- $ this ->expectExceptionMessage ('Passwords are enforced for link shares ' );
487+ $ this ->expectExceptionMessage ('Passwords are enforced for link and mail shares ' );
488488
489489 $ this ->config ->method ('getAppValue ' )->willReturnMap ([
490490 ['core ' , 'shareapi_enforce_links_password ' , 'no ' , 'yes ' ],
@@ -3464,6 +3464,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() {
34643464 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
34653465 $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
34663466
3467+ // If the password is empty, we have nothing to hash
34673468 $ this ->hasher ->expects ($ this ->never ())
34683469 ->method ('hash ' );
34693470
@@ -3531,11 +3532,12 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() {
35313532 $ manager ->expects ($ this ->once ())->method ('canShare ' )->willReturn (true );
35323533 $ manager ->expects ($ this ->once ())->method ('getShareById ' )->with ('foo:42 ' )->willReturn ($ originalShare );
35333534 $ manager ->expects ($ this ->once ())->method ('generalCreateChecks ' )->with ($ share );
3534- $ manager ->expects ($ this ->never ())->method ('verifyPassword ' );
3535+ $ manager ->expects ($ this ->once ())->method ('verifyPassword ' );
35353536 $ manager ->expects ($ this ->never ())->method ('pathCreateChecks ' );
35363537 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
35373538 $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
35383539
3540+ // If the password is empty, we have nothing to hash
35393541 $ this ->hasher ->expects ($ this ->never ())
35403542 ->method ('hash ' );
35413543
@@ -3603,11 +3605,12 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithE
36033605 $ manager ->expects ($ this ->once ())->method ('canShare ' )->willReturn (true );
36043606 $ manager ->expects ($ this ->once ())->method ('getShareById ' )->with ('foo:42 ' )->willReturn ($ originalShare );
36053607 $ manager ->expects ($ this ->once ())->method ('generalCreateChecks ' )->with ($ share );
3606- $ manager ->expects ($ this ->never ())->method ('verifyPassword ' );
3608+ $ manager ->expects ($ this ->once ())->method ('verifyPassword ' );
36073609 $ manager ->expects ($ this ->never ())->method ('pathCreateChecks ' );
36083610 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
36093611 $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
36103612
3613+ // If the password is empty, we have nothing to hash
36113614 $ this ->hasher ->expects ($ this ->never ())
36123615 ->method ('hash ' );
36133616
@@ -3649,7 +3652,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithPreviousPassword(
36493652 $ originalShare = $ this ->manager ->newShare ();
36503653 $ originalShare ->setShareType (IShare::TYPE_EMAIL )
36513654 ->setPermissions (\OCP \Constants::PERMISSION_ALL )
3652- ->setPassword ('passwordHash ' )
3655+ ->setPassword ('password ' )
36533656 ->setSendPasswordByTalk (false );
36543657
36553658 $ tomorrow = new \DateTime ();
@@ -3680,11 +3683,9 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithPreviousPassword(
36803683 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
36813684 $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
36823685
3683- $ this ->hasher ->expects ($ this ->once ())
3684- ->method ('verify ' )
3685- ->with ('password ' , 'passwordHash ' )
3686- ->willReturn (true );
3687-
3686+ // If the old & new passwords are the same, we don't do anything
3687+ $ this ->hasher ->expects ($ this ->never ())
3688+ ->method ('verify ' );
36883689 $ this ->hasher ->expects ($ this ->never ())
36893690 ->method ('hash ' );
36903691
@@ -3742,7 +3743,7 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithPreviousPassword
37423743 ->setToken ('token ' )
37433744 ->setSharedBy ('owner ' )
37443745 ->setShareOwner ('owner ' )
3745- ->setPassword ('password ' )
3746+ ->setPassword ('passwordHash ' )
37463747 ->setSendPasswordByTalk (false )
37473748 ->setExpirationDate ($ tomorrow )
37483749 ->setNode ($ file )
@@ -3751,16 +3752,14 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithPreviousPassword
37513752 $ manager ->expects ($ this ->once ())->method ('canShare ' )->willReturn (true );
37523753 $ manager ->expects ($ this ->once ())->method ('getShareById ' )->with ('foo:42 ' )->willReturn ($ originalShare );
37533754 $ manager ->expects ($ this ->once ())->method ('generalCreateChecks ' )->with ($ share );
3754- $ manager ->expects ($ this ->once ())->method ('verifyPassword ' );
3755- $ manager ->expects ($ this ->once ())->method ('pathCreateChecks ' );
3755+ $ manager ->expects ($ this ->never ())->method ('verifyPassword ' );
3756+ $ manager ->expects ($ this ->never ())->method ('pathCreateChecks ' );
37563757 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
3757- $ manager ->expects ($ this ->once ())->method ('validateExpirationDate ' );
3758-
3759- $ this ->hasher ->expects ($ this ->once ())
3760- ->method ('verify ' )
3761- ->with ('password ' , 'passwordHash ' )
3762- ->willReturn (true );
3758+ $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
37633759
3760+ // If the old & new passwords are the same, we don't do anything
3761+ $ this ->hasher ->expects ($ this ->never ())
3762+ ->method ('verify ' );
37643763 $ this ->hasher ->expects ($ this ->never ())
37653764 ->method ('hash ' );
37663765
@@ -3827,14 +3826,14 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithoutChangingPassw
38273826 $ manager ->expects ($ this ->once ())->method ('canShare ' )->willReturn (true );
38283827 $ manager ->expects ($ this ->once ())->method ('getShareById ' )->with ('foo:42 ' )->willReturn ($ originalShare );
38293828 $ manager ->expects ($ this ->once ())->method ('generalCreateChecks ' )->with ($ share );
3830- $ manager ->expects ($ this ->once ())->method ('verifyPassword ' );
3831- $ manager ->expects ($ this ->once ())->method ('pathCreateChecks ' );
3829+ $ manager ->expects ($ this ->never ())->method ('verifyPassword ' );
3830+ $ manager ->expects ($ this ->never ())->method ('pathCreateChecks ' );
38323831 $ manager ->expects ($ this ->once ())->method ('linkCreateChecks ' );
3833- $ manager ->expects ($ this ->once ())->method ('validateExpirationDate ' );
3832+ $ manager ->expects ($ this ->never ())->method ('validateExpirationDate ' );
38343833
3834+ // If the old & new passwords are the same, we don't do anything
38353835 $ this ->hasher ->expects ($ this ->never ())
38363836 ->method ('verify ' );
3837-
38383837 $ this ->hasher ->expects ($ this ->never ())
38393838 ->method ('hash ' );
38403839
0 commit comments