-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add E2E tests for moving encrypted files
These tests should be written as integration tests instead, but for practical reasons, as the integration tests have not been setup yet in the groupfolders app, they were written as E2E tests. Signed-off-by: Daniel CalviΓ±o SΓ‘nchez <danxuliu@gmail.com>
- Loading branch information
1 parent
9998a5d
commit 54e770e
Showing
3 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/** | ||
* @copyright Copyright (c) 2024 Daniel CalviΓ±o SΓ‘nchez <danxuliu@gmail.com> | ||
* | ||
* @author Daniel CalviΓ±o SΓ‘nchez <danxuliu@gmail.com> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
import { | ||
addUserToGroup, | ||
createGroup, | ||
createGroupFolder, | ||
deleteGroupFolder, | ||
disableEncryption, | ||
disableEncryptionModule, | ||
disableGroupfoldersEncryption, | ||
disableHomeStorageEncryption, | ||
enableEncryption, | ||
enableEncryptionModule, | ||
enableGroupfoldersEncryption, | ||
enableHomeStorageEncryption, | ||
enterFolder, | ||
fileOrFolderExists, | ||
PERMISSION_DELETE, | ||
PERMISSION_READ, | ||
PERMISSION_WRITE, | ||
} from './groupfoldersUtils' | ||
|
||
import { | ||
assertFileContent, | ||
moveFile, | ||
} from './files/filesUtils' | ||
|
||
import { randHash } from '../utils' | ||
|
||
import type { User } from '@nextcloud/cypress' | ||
|
||
describe('Groupfolders encryption behavior', () => { | ||
let user1: User | ||
let groupFolderId: string | ||
let groupName: string | ||
let groupFolderName: string | ||
|
||
before(() => { | ||
enableEncryptionModule() | ||
enableEncryption() | ||
}) | ||
|
||
beforeEach(() => { | ||
if (groupFolderId) { | ||
deleteGroupFolder(groupFolderId) | ||
} | ||
groupName = `test_group_${randHash()}` | ||
groupFolderName = `test_group_folder_${randHash()}` | ||
|
||
cy.createRandomUser() | ||
.then(_user => { | ||
user1 = _user | ||
}) | ||
createGroup(groupName) | ||
.then(() => { | ||
addUserToGroup(groupName, user1.userId) | ||
createGroupFolder(groupFolderName, groupName, [PERMISSION_READ, PERMISSION_WRITE, PERMISSION_DELETE]) | ||
}) | ||
}) | ||
|
||
after(() => { | ||
// Restore default values | ||
disableGroupfoldersEncryption() | ||
enableHomeStorageEncryption() | ||
disableEncryption() | ||
disableEncryptionModule() | ||
}) | ||
|
||
it('Move file from encrypted storage to encrypted groupfolder', () => { | ||
enableHomeStorageEncryption() | ||
enableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', '/file1.txt') | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
moveFile('file1.txt', groupFolderName) | ||
|
||
enterFolder(groupFolderName) | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
|
||
it('Move file from encrypted storage to non encrypted groupfolder', () => { | ||
enableHomeStorageEncryption() | ||
disableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', '/file1.txt') | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
moveFile('file1.txt', groupFolderName) | ||
|
||
enterFolder(groupFolderName) | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
|
||
it('Move file from non encrypted storage to encrypted groupfolder', () => { | ||
disableHomeStorageEncryption() | ||
enableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', '/file1.txt') | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
moveFile('file1.txt', groupFolderName) | ||
|
||
enterFolder(groupFolderName) | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
|
||
it('Move file from encrypted groupfolder to encrypted storage', () => { | ||
enableHomeStorageEncryption() | ||
enableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', `/${groupFolderName}/file1.txt`) | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
enterFolder(groupFolderName) | ||
moveFile('file1.txt', '/') | ||
|
||
cy.visit('/apps/files') | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
|
||
it('Move file from encrypted groupfolder to non encrypted storage', () => { | ||
disableHomeStorageEncryption() | ||
enableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', `/${groupFolderName}/file1.txt`) | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
enterFolder(groupFolderName) | ||
moveFile('file1.txt', '/') | ||
|
||
cy.visit('/apps/files') | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
|
||
it('Move file from non encrypted groupfolder to encrypted storage', () => { | ||
enableHomeStorageEncryption() | ||
disableGroupfoldersEncryption() | ||
|
||
cy.uploadContent(user1, new Blob(['Content of the file']), 'text/plain', `/${groupFolderName}/file1.txt`) | ||
|
||
cy.login(user1) | ||
cy.visit('/apps/files') | ||
|
||
enterFolder(groupFolderName) | ||
moveFile('file1.txt', '/') | ||
|
||
cy.visit('/apps/files') | ||
fileOrFolderExists('file1.txt') | ||
assertFileContent('file1.txt', 'Content of the file') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters