aboutsummaryrefslogtreecommitdiffstats
path: root/cypress
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-05-22 11:59:10 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-08-12 15:20:10 +0200
commitb6e28bbeffb0e9b54e64b2ced2536411a5613ff4 (patch)
treed11bc2c6733044e110abea93f4daaff26f9b7ddd /cypress
parent5559beb28c336b39a09ff0965296d7647c62d99b (diff)
downloadnextcloud-server-b6e28bbeffb0e9b54e64b2ced2536411a5613ff4.tar.gz
nextcloud-server-b6e28bbeffb0e9b54e64b2ced2536411a5613ff4.zip
chore(tests): Test limiting sharing to same group
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'cypress')
-rw-r--r--cypress/e2e/files_sharing/limit_to_same_group.cy.ts97
1 files changed, 97 insertions, 0 deletions
diff --git a/cypress/e2e/files_sharing/limit_to_same_group.cy.ts b/cypress/e2e/files_sharing/limit_to_same_group.cy.ts
new file mode 100644
index 00000000000..6d9a4170cba
--- /dev/null
+++ b/cypress/e2e/files_sharing/limit_to_same_group.cy.ts
@@ -0,0 +1,97 @@
+/**
+ * @copyright Copyright (c) 2024 Louis Chmn <louis@chmn.me>
+ *
+ * @author Louis Chmn <louis@chmn.me>
+ *
+ * @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 { User } from "@nextcloud/cypress"
+import { createShare } from "./filesSharingUtils"
+
+describe('Limit to sharing to people in the same group', () => {
+ let alice: User
+ let bob: User
+ let randomFileName1 = ''
+ let randomFileName2 = ''
+ let randomGroupName = ''
+
+ before(() => {
+ randomFileName1 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+ randomFileName2 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+ randomGroupName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
+
+ cy.runOccCommand('config:app:set core shareapi_only_share_with_group_members --value yes')
+
+ cy.createRandomUser()
+ .then(user => {
+ alice = user
+ cy.createRandomUser()
+ })
+ .then(user => {
+ bob = user
+
+ cy.runOccCommand(`group:add ${randomGroupName}`)
+ cy.runOccCommand(`group:adduser ${randomGroupName} ${alice.userId}`)
+ cy.runOccCommand(`group:adduser ${randomGroupName} ${bob.userId}`)
+
+ cy.uploadContent(alice, new Blob(['share to bob'], { type: 'text/plain' }), 'text/plain', `/${randomFileName1}`)
+ cy.uploadContent(bob, new Blob(['share by bob'], { type: 'text/plain' }), 'text/plain', `/${randomFileName2}`)
+
+ cy.login(alice)
+ cy.visit('/apps/files')
+ createShare(randomFileName1, bob.userId)
+ cy.login(bob)
+ cy.visit('/apps/files')
+ createShare(randomFileName2, alice.userId)
+ })
+ })
+
+ after(() => {
+ cy.runOccCommand('config:app:set core shareapi_only_share_with_group_members --value no')
+ })
+
+ it('Alice can see the shared file', () => {
+ cy.login(alice)
+ cy.visit('/apps/files')
+ cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${randomFileName2}"]`).should('exist')
+ })
+
+ it('Bob can see the shared file', () => {
+ cy.login(alice)
+ cy.visit('/apps/files')
+ cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${randomFileName1}"]`).should('exist')
+ })
+
+ context('Bob is removed from the group', () => {
+ before(() => {
+ cy.runOccCommand(`group:removeuser ${randomGroupName} ${bob.userId}`)
+ })
+
+ it('Alice cannot see the shared file', () => {
+ cy.login(alice)
+ cy.visit('/apps/files')
+ cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${randomFileName2}"]`).should('not.exist')
+ })
+
+ it('Bob cannot see the shared file', () => {
+ cy.login(alice)
+ cy.visit('/apps/files')
+ cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${randomFileName1}"]`).should('not.exist')
+ })
+ })
+})