|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { User } from '@nextcloud/cypress' |
| 7 | +import { AuthBackend, createStorageWithConfig, deleteAllExternalStorages, setStorageMountOptions, StorageBackend } from './StorageUtils' |
| 8 | + |
| 9 | +describe('Home folder root mount permissions', { testIsolation: true }, () => { |
| 10 | + let user1: User |
| 11 | + |
| 12 | + before(() => { |
| 13 | + cy.runOccCommand('app:enable files_external') |
| 14 | + cy.createRandomUser().then((user) => { user1 = user }) |
| 15 | + }) |
| 16 | + |
| 17 | + after(() => { |
| 18 | + deleteAllExternalStorages() |
| 19 | + cy.runOccCommand('app:disable files_external') |
| 20 | + }) |
| 21 | + |
| 22 | + it('Does not show write actions on read-only storage mounted at the root of the user\'s home folder', () => { |
| 23 | + cy.login(user1) |
| 24 | + cy.visit('/apps/files/') |
| 25 | + cy.runOccCommand('config:app:get files overwrites_home_folders --default-value=[]') |
| 26 | + .then(({ stdout }) => assert.equal(stdout.trim(), '[]')) |
| 27 | + |
| 28 | + cy.get('[data-cy-upload-picker=""]').should('exist') |
| 29 | + |
| 30 | + createStorageWithConfig('/', StorageBackend.LOCAL, AuthBackend.Null, { datadir: '/tmp' }) |
| 31 | + .then((id) => setStorageMountOptions(id, { readonly: true })) |
| 32 | + // HACK: somehow, we need to create an external folder targeting a subpath for the previous one to show. |
| 33 | + createStorageWithConfig('/a', StorageBackend.LOCAL, AuthBackend.Null, { datadir: '/tmp' }) |
| 34 | + cy.visit('/apps/files/') |
| 35 | + cy.visit('/apps/files/') |
| 36 | + cy.runOccCommand('config:app:get files overwrites_home_folders') |
| 37 | + .then(({ stdout }) => assert.equal(stdout.trim(), '["files_external"]')) |
| 38 | + cy.get('[data-cy-upload-picker=""]').should('not.exist') |
| 39 | + |
| 40 | + deleteAllExternalStorages() |
| 41 | + cy.visit('/apps/files/') |
| 42 | + cy.runOccCommand('config:app:get files overwrites_home_folders') |
| 43 | + .then(({ stdout }) => assert.equal(stdout.trim(), '[]')) |
| 44 | + cy.get('[data-cy-upload-picker=""]').should('exist') |
| 45 | + }) |
| 46 | +}) |
0 commit comments