Skip to content

Commit

Permalink
Merge pull request #11759 from nextcloud/e2e_hideStream
Browse files Browse the repository at this point in the history
Do not show "stream with" option for encrypted files
  • Loading branch information
AndyScherzinger authored Jul 4, 2023
2 parents d6158a5 + e0ada44 commit 3511dc1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,44 @@ class FileMenuFilterIT : AbstractIT() {
}
}

@Test
fun filter_stream() {
val capability = OCCapability().apply {
endToEndEncryption = CapabilityBooleanType.TRUE
}

val encryptedVideo = OCFile("/e2e/1.mpg").apply {
isEncrypted = true
mimeType = "video/mpeg"
}

val normalVideo = OCFile("/folder/2.mpg").apply {
mimeType = "video/mpeg"
fileLength = SecureRandom().nextLong()
}

configureCapability(capability)

launchActivity<TestActivity>().use {
it.onActivity { activity ->
val filterFactory =
FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)

var sut = filterFactory.newInstance(encryptedVideo, mockComponentsGetter, true, user)
var toHide = sut.getToHide(false)

// encrypted video, with content
assertTrue(toHide.contains(R.id.action_stream_media))

// regular video, with content
sut = filterFactory.newInstance(normalVideo, mockComponentsGetter, true, user)
toHide = sut.getToHide(false)

assertFalse(toHide.contains(R.id.action_stream_media))
}
}
}

private data class ExpectedLockVisibilities(
val lockFile: Boolean,
val unlockFile: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void filterExport(List<Integer> toHide) {
}

private void filterStream(List<Integer> toHide) {
if (files.isEmpty() || !isSingleFile() || !isSingleMedia()) {
if (files.isEmpty() || !isSingleFile() || !isSingleMedia() || containsEncryptedFile()) {
toHide.add(R.id.action_stream_media);
}
}
Expand Down

0 comments on commit 3511dc1

Please sign in to comment.