-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbroker.resource
More file actions
365 lines (276 loc) · 12 KB
/
broker.resource
File metadata and controls
365 lines (276 loc) · 12 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
*** Settings ***
Documentation Broker resource for the e2e tests.
...
... This is the single broker resource file. It defines all
... broker-specific variables (loaded from broker_vars.py based
... on the BROKER environment variable) and all broker keywords.
Resource kvm.resource
Resource resources/utils.resource
Resource resources/authd.resource
Library ./Browser.py AS Browser
Library Hid.py AS Hid
Library OperatingSystem
Library String
Variables ./broker_vars.py
*** Keywords ***
Enable Edge Broker
SSH.Execute sudo snap refresh ${BROKER_SNAP_NAME} --edge
Disable Broker And Purge Config
SSH.Execute sudo snap stop ${BROKER_SNAP_NAME}
SSH.Execute sudo rm ${AUTHD_BROKER_CFG}
SSH.Execute sudo systemctl restart authd.service
Log In With Remote User Through CLI: QR Code
[Arguments] ${username} ${local_password}
Start Log In With Remote User Through CLI: QR Code ${username}
Select Provider
Continue Log In With Remote User: Authenticate In External Browser
Continue Log In With Remote User Through CLI: Define Local Password ${username} ${local_password}
Start Log In With Remote User Through CLI: QR Code
[Arguments] ${username}
Try machinectl login Prompt
Hid.Type String ${username}
Hid.Keys Combo Return
Match Text Select your provider 15
Select Provider
Match Text Select your provider 15
Match Text 2. ${PROVIDER_DISPLAY_NAME}
Hid.Type String 2
Builtin.Sleep 2
Regenerate QR Code
Match Text Request new code 120
Hid.Keys Combo Return
Match Text ${DEVICE_URL} 15
Continue Log In With Remote User: Authenticate In External Browser
# Wait until the verification URL and login code are displayed
Match Text ${DEVICE_URL}
# Read the user code.
${text} = Read Text
${user_code} = StringUtils.First Match ${DEVICE_URL_REGEX} ${text}
# The OCR sometimes reads spaces in the user code, even though there are none,
# so remove any spaces.
${user_code} = Remove String ${user_code} ${SPACE}
# The user code is all uppercase, but sometimes the OCR reads some letters as lowercase,
# so convert it to uppercase to handle that.
${user_code} = String.Convert To Upper Case ${user_code}
Browser.Login ${user_code} ${SUITE_OUTPUT_DIR}
Continue Log In With Remote User Through CLI: Define Local Password
[Arguments] ${username} ${local_password}
# The terminal should now be visible and focused again.
# Check that we're prompted to set a local password.
Match Text New password: 120
# Set a local password
Hid.Type String ${local_password}
Hid.Keys Combo Return
# Confirm the local password
Match Text Confirm password:
Hid.Type String ${local_password}
Hid.Keys Combo Return
# Wait for the login to complete
${timeout_sec} = Set Variable 120
Match Text ${username}@ubuntu ${timeout_sec}
Log In With Remote User Through CLI: Local Password
[Arguments] ${username} ${local_password}
Hid.Type String clear
Hid.Keys Combo Return
Try machinectl login Prompt
Hid.Type String ${username}
Hid.Keys Combo Return
Builtin.Sleep 2
Match Text Enter your local password: 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Builtin.Sleep 2
Match Text ${username}@ubuntu:~$ 120
Try Changing Username In sudo su Log In
Hid.Type String sudo su
Hid.Keys Combo Return
Try Navigating Back to User Selection
Cancel Operation
Try Changing Username In su Log In
[Arguments] ${username}
Hid.Type String su ${username}
Hid.Keys Combo Return
Try Navigating Back to User Selection
Cancel Operation
Try Navigating Back to User Selection
# First screen is the autoselected local password mode
Match Text Enter your local password: 120
Hid.Keys Combo Escape
# The previous screen should be the authentication mode selection
Match Text Select your authentication method 120
Hid.Keys Combo Escape
# The previous screen should be the broker selection
Match Text Select your provider 120
Hid.Keys Combo Escape
# The previous screen is the username prompt, but it shouldn't be possible to get there
Match Text Select your provider 120
Hid.Keys Combo Escape
Match Text Select your provider 120
Log In With Remote User Through CLI: Local Password And Expect Failure
[Arguments] ${username} ${local_password}
Hid.Type String clear
Hid.Keys Combo Return
Try machinectl login Prompt
Hid.Type String ${username}
Hid.Keys Combo Return
Builtin.Sleep 2
Match Text Enter your local password: 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Check That Remote User Is Not Allowed To Log In
# Exit the machinectl session (three ^] within 1 s exits the session).
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
# Wait until the shell prompt is back before the next login attempt.
Match Text @ubuntu:~$ 30
Remove Registered Owner
[Documentation] Removes the auto-registration drop-in that the broker creates when
... the first user logs in, so that subsequent OWNER-based tests start
... from a known-clean state.
SSH.Execute sudo rm -f ${BROKER_CFG_DIR}/20-owner-autoregistration.conf
SSH.Execute sudo snap restart ${BROKER_SNAP_NAME}
# Uses sed to change the broker configuration.
# It should match both commented and uncommented lines.
# The full command looks like:
# sed -i 's/#*${config_key} = .*/${config_key} = ${config_value}/g' ${BROKER_CFG}
Change Broker Configuration
[Arguments] ${config_key} ${config_value}
SSH.Execute sudo sed -i 's/^#*${config_key} =.*/${config_key} = ${config_value}/g' ${BROKER_CFG}
SSH.Execute sudo snap restart ${BROKER_SNAP_NAME}
# Pretty much the same as the function above, but since YARF does not have support for
# shifted characters yet, we need to do some workarounds.
Change allowed_users In Broker Configuration
[Arguments] ${config_value}
SSH.Execute sudo sed -i 's/^#*allowed_users =.*/allowed_users = ${config_value}/g' ${BROKER_CFG}
SSH.Execute sudo snap restart ${BROKER_SNAP_NAME}
Comment Key In Broker Configuration
[Arguments] ${config_key}
SSH.Execute sudo sed -i 's/^#*${config_key} =.*/#${config_key} = .*/g' ${BROKER_CFG}
SSH.Execute sudo snap restart ${BROKER_SNAP_NAME}
Log In With Remote User Through SSH: QR Code
[Arguments] ${username} ${local_password}
Start Log In With Remote User Through SSH: QR Code ${username}
Select Provider through SSH
Continue Log In With Remote User: Authenticate In External Browser
Continue Log In With Remote User Through SSH: QR Code
Continue Log In With Remote User Through SSH: Define Local Password ${username} ${local_password}
Start Log In With Remote User Through SSH: QR Code
[Arguments] ${username}
Hid.Type String ssh ${username}@localhost
Hid.Keys Combo Return
Builtin.Sleep 2
Hid.Type String yes
Hid.Keys Combo Return
Select Provider through SSH
Match Text 2. ${PROVIDER_DISPLAY_NAME} 120
Match Text Choose your provider: 120
Hid.Type String 2
Hid.Keys Combo Return
Continue Log In With Remote User Through SSH: QR Code
Match Text Choose action: 120
Hid.Type String 1
Hid.Keys Combo Return
Continue Log In With Remote User Through SSH: Define Local Password
[Arguments] ${username} ${local_password}
Match Text Create a local password: 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Match Text Confirm Password: 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Match Text ${username}@ubuntu:~$ 120
Log In With Remote User Through SSH: Local Password
[Arguments] ${username} ${local_password}
Hid.Type String ssh ${username}@localhost
Hid.Keys Combo Return
Match Text Enter your local password: 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Match Text ${username}@ubuntu:~$ 120
Log In With Remote User Through GDM: QR Code
[Arguments] ${username} ${local_password}
Start Log In With Remote User Through GDM: QR Code ${username}
Select Broker Through GDM
Continue Log In With Remote User: Authenticate In External Browser
Continue Log In With Remote User Through GDM: Define Local Password ${local_password}
Start Log In With Remote User Through GDM: QR Code
[Arguments] ${username}
Match Text Not listed 180
Move Pointer To Not listed
Left Button Click
# Enter the username
Match Text Username
Hid.Type String ${username}
Hid.Keys Combo Return
Select Broker Through GDM
Match Text Select the broker 120
Move Pointer To ${PROVIDER_DISPLAY_NAME}
Left Button Click
Builtin.Sleep 1
Continue Log In With Remote User Through GDM: Define Local Password
[Arguments] ${local_password}
Match Text Create a local password 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Match Text Please, type the new passphrase again 120
Hid.Type String ${local_password}
Hid.Keys Combo Return
Wait Until Desktop Ready
Log In With Remote User Through GDM: Local Password
[Arguments] ${username} ${local_password}
Match Text Not listed 180
Move Pointer To Not listed
Left Button Click
# Enter the username
Match Text Username
Hid.Type String ${username}
Hid.Keys Combo Return
# Enter the password
Match Text Password
Hid.Type String ${local_password}
Hid.Keys Combo Return
Wait Until Desktop Ready
Check User Information
[Arguments] ${username}
Match Text ${username}:x: 120
Check Configuration Value
[Arguments] ${config_key} ${expected_value}
Hid.Type String cat ${BROKER_CFG}
# TODO: Even though the Hid.Type String works for most characters now, it seems like there are still issues with
# some special characters like `|`, so we still need the workaround here.
Hid.Keys Combo Shift_L |
Hid.Type String grep ${config_key}
Hid.Keys Combo Return
Match Text ${expected_value} 120
Check If Owner Was Registered
[Arguments] ${username}
Hid.Type String cat ${BROKER_CFG_DIR}/20-owner-autoregistration.conf
Hid.Keys Combo Return
Match Text owner = ${username} 120
Check Home Directory
[Arguments] ${username}
Hid.Type String echo $HOME
Hid.Keys Combo Return
Match Text /home/${username} 120
Hid.Type String stat -c %U:%G $HOME
Hid.Keys Combo Return
Match Text ${username}:${username}
Check That Remote User Is Not Allowed To Log In
Match Text authentication failure: user not allowed in broker configuration 120
Check That Login Is Handled By PAM Unix
Match Text Password:
Check That SSH Connection Is Closed
Match Text Connection closed
Check If User Was Added Properly
[Arguments] ${username}
Get NSS Passwd Entry For Remote User ${username}
Check User Information ${username}
IF '${BROKER_SNAP_NAME}' == 'authd-msentraid'
Get NSS Group Entries For Remote User ${username}
Check User Groups ${username} ${remote_group}
Check That Remote User Can Run Sudo Commands ${local_password}
END
Check User Groups
[Arguments] ${username} ${remote_group}
Match Text ${username} sudo ${remote_group} 120