1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { User } from '@nextcloud/cypress'
import { AuthBackend, createStorageWithConfig, StorageBackend } from './StorageUtils'
import { getRowForFile } from '../files/FilesUtils'
describe('Files user credentials', { testIsolation: true }, () => {
let currentUser: User
beforeEach(() => {
})
before(() => {
cy.runOccCommand('app:enable files_external')
cy.createRandomUser().then((user) => { currentUser = user })
})
afterEach(() => {
// Cleanup global storages
cy.runOccCommand('files_external:list --output=json').then(({ stdout }) => {
const list = JSON.parse(stdout)
list.forEach((storage) => cy.runOccCommand(`files_external:delete --yes ${storage.mount_id}`), { failOnNonZeroExit: false })
})
})
after(() => {
cy.runOccCommand('app:disable files_external')
})
it('Create a failed user storage with invalid url', () => {
const url = 'http://cloud.domain.com/remote.php/dav/files/abcdef123456'
createStorageWithConfig('Storage1', StorageBackend.DAV, AuthBackend.LoginCredentials, { host: url.replace('index.php/', ''), secure: 'false' })
cy.login(currentUser)
cy.visit('/apps/files')
// Ensure the row is visible and marked as unavailable
getRowForFile('Storage1').as('row').should('be.visible')
cy.get('@row').find('[data-cy-files-list-row-name-link]')
.should('have.attr', 'title', 'This node is unavailable')
// Ensure clicking on the location does not open the folder
cy.location().then((loc) => {
cy.get('@row').find('[data-cy-files-list-row-name-link]').click()
cy.location('href').should('eq', loc.href)
})
})
it('Create a failed user storage with invalid login credentials', () => {
const url = 'http://cloud.domain.com/remote.php/dav/files/abcdef123456'
createStorageWithConfig('Storage2', StorageBackend.DAV, AuthBackend.Password, {
host: url.replace('index.php/', ''),
user: 'invaliduser',
password: 'invalidpassword',
secure: 'false',
})
cy.login(currentUser)
cy.visit('/apps/files')
// Ensure the row is visible and marked as unavailable
getRowForFile('Storage2').as('row').should('be.visible')
cy.get('@row').find('[data-cy-files-list-row-name-link]')
.should('have.attr', 'title', 'This node is unavailable')
// Ensure clicking on the location does not open the folder
cy.location().then((loc) => {
cy.get('@row').find('[data-cy-files-list-row-name-link]').click()
cy.location('href').should('eq', loc.href)
})
})
})
|