Skip to content

Commit

Permalink
Restore delete functionality for E2EE - fixes #11387
Browse files Browse the repository at this point in the history
Added test for an encrypted file:
- remove functionality *not* filtered
- set/unset encryption, move/copy and rename filtered

Signed-off-by: Marco Baggio <[email protected]>
  • Loading branch information
mawumag committed Jan 10, 2024
1 parent fb3694f commit 65b7513
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class FileMenuFilterIT : AbstractIT() {
mimeType = MimeType.DIRECTORY
}

val encryptedFile = OCFile("/foo.md").apply {
isEncrypted = true
}

configureCapability(capability)

launchActivity<TestActivity>().use {
Expand Down Expand Up @@ -227,6 +231,16 @@ class FileMenuFilterIT : AbstractIT() {
assertTrue(toHide.contains(R.id.action_unset_encrypted))
assertFalse(toHide.contains(R.id.action_encrypted))
assertFalse(toHide.contains(R.id.action_remove_file))

// encrypted file
sut = filterFactory.newInstance(encryptedFile, mockComponentsGetter, true, user)
toHide = sut.getToHide(false)

assertTrue(toHide.contains(R.id.action_unset_encrypted))
assertTrue(toHide.contains(R.id.action_encrypted))
assertTrue(toHide.contains(R.id.action_move_or_copy))
assertTrue(toHide.contains(R.id.action_rename_file))
assertFalse(toHide.contains(R.id.action_remove_file))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ private void filterSelectAll(List<Integer> toHide, boolean inSingleFileFragment)
}

private void filterRemove(List<Integer> toHide, boolean synchronizing) {
if (files.isEmpty() || synchronizing || containsLockedFile()
|| containsEncryptedFolder() || containsEncryptedFile()) {
if (files.isEmpty() || synchronizing || containsLockedFile() || isEncryptedRoot()) {
toHide.add(R.id.action_remove_file);
}
}
Expand Down Expand Up @@ -566,4 +565,8 @@ private boolean isShared() {
}
return false;
}

private boolean isEncryptedRoot() {
return isEncryptedFolder() && !hasEncryptedParent();
}
}

0 comments on commit 65b7513

Please sign in to comment.