@@ -122,6 +122,10 @@ protected function setUp(): void {
122122 * test if public key from one of the recipients is missing
123123 */
124124 public function testEndUser1 () {
125+ $ this ->sessionMock ->expects ($ this ->once ())
126+ ->method ('decryptAllModeActivated ' )
127+ ->willReturn (false );
128+
125129 $ this ->instance ->begin ('/foo/bar ' , 'user1 ' , 'r ' , [], ['users ' => ['user1 ' , 'user2 ' , 'user3 ' ]]);
126130 $ this ->endTest ();
127131 }
@@ -131,6 +135,10 @@ public function testEndUser1() {
131135 *
132136 */
133137 public function testEndUser2 () {
138+ $ this ->sessionMock ->expects ($ this ->once ())
139+ ->method ('decryptAllModeActivated ' )
140+ ->willReturn (false );
141+
134142 $ this ->expectException (\OCA \Encryption \Exceptions \PublicKeyMissingException::class);
135143
136144 $ this ->instance ->begin ('/foo/bar ' , 'user2 ' , 'r ' , [], ['users ' => ['user1 ' , 'user2 ' , 'user3 ' ]]);
@@ -252,35 +260,16 @@ public function dataTestBegin() {
252260 */
253261 public function testBeginDecryptAll () {
254262 $ path = '/user/files/foo.txt ' ;
255- $ recoveryKeyId = 'recoveryKeyId ' ;
256- $ recoveryShareKey = 'recoveryShareKey ' ;
257- $ decryptAllKey = 'decryptAllKey ' ;
258263 $ fileKey = 'fileKey ' ;
259264
260265 $ this ->sessionMock ->expects ($ this ->once ())
261266 ->method ('decryptAllModeActivated ' )
262267 ->willReturn (true );
263- $ this ->sessionMock ->expects ($ this ->once ())
264- ->method ('getDecryptAllUid ' )
265- ->willReturn ($ recoveryKeyId );
266- $ this ->sessionMock ->expects ($ this ->once ())
267- ->method ('getDecryptAllKey ' )
268- ->willReturn ($ decryptAllKey );
269-
270- $ this ->keyManagerMock ->expects ($ this ->once ())
271- ->method ('getEncryptedFileKey ' )
272- ->willReturn ('encryptedFileKey ' );
273268 $ this ->keyManagerMock ->expects ($ this ->once ())
274- ->method ('getShareKey ' )
275- ->with ($ path , $ recoveryKeyId )
276- ->willReturn ($ recoveryShareKey );
277- $ this ->cryptMock ->expects ($ this ->once ())
278- ->method ('multiKeyDecryptLegacy ' )
279- ->with ('encryptedFileKey ' , $ recoveryShareKey , $ decryptAllKey )
269+ ->method ('getFileKey ' )
270+ ->with ($ path , 'user ' , null , true )
280271 ->willReturn ($ fileKey );
281272
282- $ this ->keyManagerMock ->expects ($ this ->never ())->method ('getFileKey ' );
283-
284273 $ this ->instance ->begin ($ path , 'user ' , 'r ' , [], []);
285274
286275 $ this ->assertSame ($ fileKey ,
@@ -294,6 +283,10 @@ public function testBeginDecryptAll() {
294283 * and continue
295284 */
296285 public function testBeginInitMasterKey () {
286+ $ this ->sessionMock ->expects ($ this ->once ())
287+ ->method ('decryptAllModeActivated ' )
288+ ->willReturn (false );
289+
297290 $ this ->sessionMock ->expects ($ this ->once ())->method ('isReady ' )->willReturn (false );
298291 $ this ->utilMock ->expects ($ this ->once ())->method ('isMasterKeyEnabled ' )
299292 ->willReturn (true );
0 commit comments