@@ -15,15 +15,16 @@ describe('Files user credentials', { testIsolation: true }, () => {
1515 let user2 : User
1616 let storageUser : User
1717
18- beforeEach ( ( ) => {
19- } )
20-
2118 before ( ( ) => {
2219 cy . runOccCommand ( 'app:enable files_external' )
2320
2421 // Create some users
25- cy . createRandomUser ( ) . then ( ( user ) => user1 = user )
26- cy . createRandomUser ( ) . then ( ( user ) => user2 = user )
22+ cy . createRandomUser ( ) . then ( ( user ) => {
23+ user1 = user
24+ } )
25+ cy . createRandomUser ( ) . then ( ( user ) => {
26+ user2 = user
27+ } )
2728
2829 // This user will hold the webdav storage
2930 cy . createRandomUser ( ) . then ( ( user ) => {
@@ -34,7 +35,7 @@ describe('Files user credentials', { testIsolation: true }, () => {
3435
3536 after ( ( ) => {
3637 // Cleanup global storages
37- cy . runOccCommand ( ` files_external:list --output=json` ) . then ( ( { stdout} ) => {
38+ cy . runOccCommand ( ' files_external:list --output=json' ) . then ( ( { stdout } ) => {
3839 const list = JSON . parse ( stdout )
3940 list . forEach ( ( storage ) => cy . runOccCommand ( `files_external:delete --yes ${ storage . mount_id } ` ) , { failOnNonZeroExit : false } )
4041 } )
@@ -43,8 +44,10 @@ describe('Files user credentials', { testIsolation: true }, () => {
4344 } )
4445
4546 it ( 'Create a user storage with user credentials' , ( ) => {
46- const url = Cypress . config ( 'baseUrl' ) + '/remote.php/dav/files/' + storageUser . userId
47- createStorageWithConfig ( storageUser . userId , StorageBackend . DAV , AuthBackend . UserProvided , { host : url . replace ( 'index.php/' , '' ) , 'secure' : 'false' } )
47+ // Its not the public server address but the address so the server itself can connect to it
48+ const base = 'http://localhost'
49+ const host = `${ base } /remote.php/dav/files/${ storageUser . userId } `
50+ createStorageWithConfig ( storageUser . userId , StorageBackend . DAV , AuthBackend . UserProvided , { host, secure : 'false' } )
4851
4952 cy . login ( user1 )
5053 cy . visit ( '/apps/files/extstoragemounts' )
@@ -71,7 +74,8 @@ describe('Files user credentials', { testIsolation: true }, () => {
7174 cy . wait ( '@setCredentials' )
7275
7376 // Auth dialog should be closed and the set credentials button should be gone
74- authDialog . should ( 'not.exist' , { timeout : 2000 } )
77+ cy . get ( '@authDialog' ) . should ( 'not.exist' , { timeout : 2000 } )
78+
7579 getActionEntryForFile ( storageUser . userId , ACTION_CREDENTIALS_EXTERNAL_STORAGE ) . should ( 'not.exist' )
7680
7781 // Finally, the storage should be accessible
@@ -81,8 +85,10 @@ describe('Files user credentials', { testIsolation: true }, () => {
8185 } )
8286
8387 it ( 'Create a user storage with GLOBAL user credentials' , ( ) => {
84- const url = Cypress . config ( 'baseUrl' ) + '/remote.php/dav/files/' + storageUser . userId
85- createStorageWithConfig ( 'storage1' , StorageBackend . DAV , AuthBackend . UserGlobalAuth , { host : url . replace ( 'index.php/' , '' ) , 'secure' : 'false' } )
88+ // Its not the public server address but the address so the server itself can connect to it
89+ const base = 'http://localhost'
90+ const host = `${ base } /remote.php/dav/files/${ storageUser . userId } `
91+ createStorageWithConfig ( 'storage1' , StorageBackend . DAV , AuthBackend . UserGlobalAuth , { host, secure : 'false' } )
8692
8793 cy . login ( user2 )
8894 cy . visit ( '/apps/files/extstoragemounts' )
@@ -93,23 +99,32 @@ describe('Files user credentials', { testIsolation: true }, () => {
9399 triggerInlineActionForFile ( 'storage1' , ACTION_CREDENTIALS_EXTERNAL_STORAGE )
94100
95101 // See credentials dialog
96- const storageDialog = cy . findByRole ( 'dialog' , { name : 'Storage credentials' } )
97- storageDialog . should ( 'be.visible' )
98- storageDialog . findByRole ( 'textbox' , { name : 'Login' } ) . type ( storageUser . userId )
99- storageDialog . get ( 'input[type="password"]' ) . type ( storageUser . password )
100- storageDialog . get ( 'button' ) . contains ( 'Confirm' ) . click ( )
101- storageDialog . should ( 'not.exist' )
102+ cy . findByRole ( 'dialog' , { name : 'Storage credentials' } )
103+ . as ( 'storageDialog' )
104+ cy . get ( '@storageDialog' )
105+ . should ( 'be.visible' )
106+ . findByRole ( 'textbox' , { name : 'Login' } )
107+ . type ( storageUser . userId )
108+ cy . get ( '@storageDialog' )
109+ . find ( 'input[type="password"]' )
110+ . type ( storageUser . password )
111+ cy . get ( '@storageDialog' )
112+ . contains ( 'button' , 'Confirm' )
113+ . click ( )
114+ cy . get ( '@storageDialog' )
115+ . should ( 'not.exist' )
102116
103117 // Storage dialog now closed, the user auth dialog should be visible
104- const authDialog = cy . findByRole ( 'dialog' , { name : 'Confirm your password' } )
105- authDialog . should ( 'be.visible' )
118+ cy . findByRole ( 'dialog' , { name : 'Confirm your password' } )
119+ . as ( 'authDialog' )
120+ . should ( 'be.visible' )
106121 handlePasswordConfirmation ( user2 . password )
107122
108123 // Wait for the credentials to be set
109124 cy . wait ( '@setCredentials' )
110125
111126 // Auth dialog should be closed and the set credentials button should be gone
112- authDialog . should ( 'not.exist' , { timeout : 2000 } )
127+ cy . get ( '@ authDialog' ) . should ( 'not.exist' , { timeout : 2000 } )
113128 getActionEntryForFile ( 'storage1' , ACTION_CREDENTIALS_EXTERNAL_STORAGE ) . should ( 'not.exist' )
114129
115130 // Finally, the storage should be accessible
@@ -119,8 +134,10 @@ describe('Files user credentials', { testIsolation: true }, () => {
119134 } )
120135
121136 it ( 'Create another user storage while reusing GLOBAL user credentials' , ( ) => {
122- const url = Cypress . config ( 'baseUrl' ) + '/remote.php/dav/files/' + storageUser . userId
123- createStorageWithConfig ( 'storage2' , StorageBackend . DAV , AuthBackend . UserGlobalAuth , { host : url . replace ( 'index.php/' , '' ) , 'secure' : 'false' } )
137+ // Its not the public server address but the address so the server itself can connect to it
138+ const base = 'http://localhost'
139+ const host = `${ base } /remote.php/dav/files/${ storageUser . userId } `
140+ createStorageWithConfig ( 'storage2' , StorageBackend . DAV , AuthBackend . UserGlobalAuth , { host, secure : 'false' } )
124141
125142 cy . login ( user2 )
126143 cy . visit ( '/apps/files/extstoragemounts' )
0 commit comments