File tree 4 files changed +53
-16
lines changed
4 files changed +53
-16
lines changed Original file line number Diff line number Diff line change 153
153
cfg = config . test . login ;
154
154
in {
155
155
options . test . login = {
156
- usernameFieldLabel = mkOption {
156
+ usernameFieldLabelRegex = mkOption {
157
157
type = str ;
158
158
default = "username" ;
159
159
} ;
160
- passwordFieldLabel = mkOption {
160
+ passwordFieldLabelRegex = mkOption {
161
161
type = str ;
162
162
default = "password" ;
163
163
} ;
164
- loginButtonName = mkOption {
164
+ loginButtonNameRegex = mkOption {
165
165
type = str ;
166
166
default = "login" ;
167
167
} ;
241
241
page.goto(testCfg['startUrl'])
242
242
243
243
if u['username'] is not None:
244
- print(f"Filling field {testCfg['usernameFieldLabel ']} with {u['username']}")
245
- page.get_by_label(testCfg['usernameFieldLabel'] ).fill(u['username'])
244
+ print(f"Filling field {testCfg['usernameFieldLabelRegex ']} with {u['username']}")
245
+ page.get_by_label(re.compile( testCfg['usernameFieldLabelRegex']) ).fill(u['username'])
246
246
if u['password'] is not None:
247
- print(f"Filling field {testCfg['passwordFieldLabel ']} with {u['password']}")
248
- page.get_by_label(testCfg['passwordFieldLabel'] ).fill(u['password'])
247
+ print(f"Filling field {testCfg['passwordFieldLabelRegex ']} with {u['password']}")
248
+ page.get_by_label(re.compile( testCfg['passwordFieldLabelRegex']) ).fill(u['password'])
249
249
250
- print(f"Clicking button {testCfg['loginButtonName ']}")
251
- page.get_by_role("button", name=testCfg['loginButtonName'] ).click()
250
+ print(f"Clicking button {testCfg['loginButtonNameRegex ']}")
251
+ page.get_by_role("button", name=re.compile( testCfg['loginButtonNameRegex']) ).click()
252
252
253
253
for line in u['nextPageExpect']:
254
254
print(f"Running: {line}")
Original file line number Diff line number Diff line change 108
108
} ;
109
109
110
110
test . login = {
111
- passwordFieldLabel = "Password" ;
112
- loginButtonName = "Login" ;
111
+ passwordFieldLabelRegex = "Password" ;
112
+ loginButtonNameRegex = "Login" ;
113
113
testLoginWith = [
114
114
{ password = "deluge" ; nextPageExpect = [
115
115
"expect(page.get_by_role('button', name='Login')).not_to_be_visible()"
Original file line number Diff line number Diff line change 80
80
81
81
test . login = {
82
82
startUrl = "http://${ config . test . fqdn } /user/login" ;
83
- usernameFieldLabel = "Username or email address" ;
84
- passwordFieldLabel = "Password" ;
85
- loginButtonName = "Sign In" ;
83
+ usernameFieldLabelRegex = "Username or email address" ;
84
+ passwordFieldLabelRegex = "Password" ;
85
+ loginButtonNameRegex = "Sign In" ;
86
86
testLoginWith = [
87
87
{ username = "theadmin" ; password = adminPassword + "oops" ; nextPageExpect = [
88
88
"expect(page.get_by_text('Username or password is incorrect.')).to_be_visible()"
Original file line number Diff line number Diff line change 110
110
} ;
111
111
112
112
basic = { config , ... } : {
113
+ imports = [
114
+ testLib . baseModule
115
+ ../../modules/services/nextcloud-server.nix
116
+ ] ;
117
+
113
118
test = {
114
119
subdomain = "n" ;
115
120
} ;
136
141
} ;
137
142
} ;
138
143
144
+ clientLogin = { config , ... } : {
145
+ imports = [
146
+ testLib . baseModule
147
+ testLib . clientLoginModule
148
+ ] ;
149
+ virtualisation . memorySize = 4096 ;
150
+
151
+ test = {
152
+ subdomain = "n" ;
153
+ } ;
154
+
155
+ test . login = {
156
+ startUrl = "http://${ config . test . fqdn } " ;
157
+ usernameFieldLabelRegex = "[Uu]sername" ;
158
+ passwordFieldLabelRegex = "^ *[Pp]assword" ;
159
+ loginButtonNameRegex = "[Ll]og [Ii]n" ;
160
+ testLoginWith = [
161
+ { username = adminUser ; password = adminPass + "oops" ; nextPageExpect = [
162
+ "expect(page.get_by_text('Wrong username or password')).to_be_visible()"
163
+ ] ; }
164
+ { username = adminUser ; password = adminPass ; nextPageExpect = [
165
+ "expect(page.get_by_text('Wrong username or password')).not_to_be_visible()"
166
+ "expect(page.get_by_role('button', name=re.compile('[Ll]og [Ii]n'))).not_to_be_visible()"
167
+ "expect(page).to_have_title(re.compile('Dashboard'))"
168
+ ] ; }
169
+ ] ;
170
+ } ;
171
+ } ;
172
+
139
173
https = { config , ...} : {
140
174
shb . nextcloud = {
141
175
ssl = config . shb . certs . certs . selfsigned . n ;
234
268
basic = pkgs . testers . runNixOSTest {
235
269
name = "nextcloud_basic" ;
236
270
271
+ nodes . client = {
272
+ imports = [
273
+ clientLogin
274
+ ] ;
275
+ } ;
237
276
nodes . server = {
238
277
imports = [
239
- testLib . baseModule
240
- ../../modules/services/nextcloud-server.nix
241
278
basic
242
279
] ;
243
280
} ;
You can’t perform that action at this time.
0 commit comments