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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { ShareContext } from './setup-public-share.ts'
import type { ShareOptions } from '../ShareOptionsType.ts'
import { defaultShareOptions } from '../ShareOptionsType.ts'
import { setupData, createShare } from './setup-public-share.ts'
describe('files_sharing: Before create checks', () => {
let shareContext: ShareContext
before(() => {
// Setup data for the shared folder once before all tests
cy.createRandomUser().then((randomUser) => {
shareContext = {
user: randomUser,
}
})
})
afterEach(() => {
cy.runOccCommand('config:app:delete core shareapi_enable_link_password_by_default')
cy.runOccCommand('config:app:delete core shareapi_enforce_links_password')
cy.runOccCommand('config:app:delete core shareapi_default_expire_date')
cy.runOccCommand('config:app:delete core shareapi_enforce_expire_date')
cy.runOccCommand('config:app:delete core shareapi_expire_after_n_days')
})
const applyShareOptions = (options: ShareOptions = defaultShareOptions): void => {
cy.runOccCommand(`config:app:set --value ${options.alwaysAskForPassword ? 'yes' : 'no'} core shareapi_enable_link_password_by_default`)
cy.runOccCommand(`config:app:set --value ${options.enforcePassword ? 'yes' : 'no'} core shareapi_enforce_links_password`)
cy.runOccCommand(`config:app:set --value ${options.enforceExpirationDate ? 'yes' : 'no'} core shareapi_enforce_expire_date`)
cy.runOccCommand(`config:app:set --value ${options.defaultExpirationDateSet ? 'yes' : 'no'} core shareapi_default_expire_date`)
if (options.defaultExpirationDateSet) {
cy.runOccCommand('config:app:set --value 2 core shareapi_expire_after_n_days')
}
}
it('Checks if user can create share when both password and expiration date are enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: true,
enforceExpirationDate: true,
defaultExpirationDateSet: true,
}
applyShareOptions(shareOptions)
const shareName = 'passwordAndExpireEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share when password is enforced and expiration date has a default set', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: true,
defaultExpirationDateSet: true,
}
applyShareOptions(shareOptions)
const shareName = 'passwordEnforcedDefaultExpire'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share when password is optionally requested and expiration date is enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
defaultExpirationDateSet: true,
enforceExpirationDate: true,
}
applyShareOptions(shareOptions)
const shareName = 'defaultPasswordExpireEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share when password is optionally requested and expiration date have defaults set', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
defaultExpirationDateSet: true,
}
applyShareOptions(shareOptions)
const shareName = 'defaultPasswordAndExpire'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share with password enforced and expiration date set but not enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: true,
defaultExpirationDateSet: true,
enforceExpirationDate: false,
}
applyShareOptions(shareOptions)
const shareName = 'passwordEnforcedExpireSetNotEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create a share when both password and expiration date have default values but are both not enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: false,
defaultExpirationDateSet: true,
enforceExpirationDate: false,
}
applyShareOptions(shareOptions)
const shareName = 'defaultPasswordAndExpirationNotEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share with password not enforced but expiration date enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: false,
defaultExpirationDateSet: true,
enforceExpirationDate: true,
}
applyShareOptions(shareOptions)
const shareName = 'noPasswordExpireEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share with password not enforced and expiration date has a default set', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: false,
defaultExpirationDateSet: true,
enforceExpirationDate: false,
}
applyShareOptions(shareOptions)
const shareName = 'defaultExpireNoPasswordEnforced'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share with expiration date set and password not enforced', () => {
const shareOptions : ShareOptions = {
alwaysAskForPassword: true,
enforcePassword: false,
defaultExpirationDateSet: true,
}
applyShareOptions(shareOptions)
const shareName = 'noPasswordExpireDefault'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, shareOptions).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
it('Checks if user can create share with password not enforced, expiration date not enforced, and no defaults set', () => {
applyShareOptions()
const shareName = 'noPasswordNoExpireNoDefaults'
setupData(shareContext.user, shareName)
createShare(shareContext, shareName, null).then((shareUrl) => {
shareContext.url = shareUrl
cy.log(`Created share with URL: ${shareUrl}`)
})
})
})
|