/
attach_validtoken.feature
322 lines (299 loc) · 13.3 KB
/
attach_validtoken.feature
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
@uses.config.contract_token
Feature: Command behaviour when attaching a machine to an Ubuntu Advantage
subscription using a valid token
@series.hirsute
@series.impish
@uses.config.machine_type.lxd.container
Scenario Outline: Attached command in a non-lts ubuntu machine
Given a `<release>` machine with ubuntu-advantage-tools installed
When I attach `contract_token` with sudo
And I run `ua status --all` as non-root
Then stdout matches regexp:
"""
SERVICE ENTITLED STATUS DESCRIPTION
cc-eal +yes +n/a +Common Criteria EAL2 Provisioning Packages
cis +yes +n/a +Center for Internet Security Audit Tools
esm-apps +yes +n/a +UA Apps: Extended Security Maintenance \(ESM\)
esm-infra +yes +n/a +UA Infra: Extended Security Maintenance \(ESM\)
fips +yes +n/a +NIST-certified core packages
fips-updates +yes +n/a +NIST-certified core packages with priority security updates
livepatch +yes +n/a +Canonical Livepatch service
"""
Examples: ubuntu release
| release |
| hirsute |
| impish |
@series.lts
@uses.config.machine_type.lxd.container
Scenario Outline: Attach command in a ubuntu lxd container
Given a `<release>` machine with ubuntu-advantage-tools installed
When I run `apt-get update` with sudo, retrying exit [100]
And I run `DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y <downrev_pkg>` with sudo, retrying exit [100]
And I run `run-parts /etc/update-motd.d/` with sudo
Then if `<release>` in `xenial` and stdout matches regexp:
"""
\d+ update(s)? can be applied immediately.
\d+ of these updates (is a|are) standard security update(s)?.
"""
Then if `<release>` in `bionic` and stdout matches regexp:
"""
\d+ update(s)? can be applied immediately.
\d+ of these updates (is a|are) standard security update(s)?.
"""
Then if `<release>` in `focal` and stdout matches regexp:
"""
\d+ update(s)? can be applied immediately.
"""
When I attach `contract_token` with sudo
Then stdout matches regexp:
"""
UA Infra: ESM enabled
"""
And stdout matches regexp:
"""
This machine is now attached to
"""
And stdout matches regexp:
"""
SERVICE ENTITLED STATUS DESCRIPTION
cc-eal +yes +<cc_status> +Common Criteria EAL2 Provisioning Packages
cis +yes +disabled +Center for Internet Security Audit Tools
esm-apps +yes +enabled +UA Apps: Extended Security Maintenance \(ESM\)
esm-infra +yes +enabled +UA Infra: Extended Security Maintenance \(ESM\)
fips +yes +n/a +NIST-certified core packages
fips-updates +yes +n/a +NIST-certified core packages with priority security updates
livepatch +yes +n/a +Canonical Livepatch service
"""
And stderr matches regexp:
"""
Enabling default service esm-infra
"""
When I run `ua disable esm-apps --assume-yes` with sudo
When I append the following on uaclient config:
"""
features:
allow_beta: true
"""
And I run `apt update` with sudo
And I delete the file `/var/lib/ubuntu-advantage/jobs-status.json`
And I run `python3 /usr/lib/ubuntu-advantage/timer.py` with sudo
And I run `apt install update-motd` with sudo, retrying exit [100]
And I run `update-motd` with sudo
Then if `<release>` in `focal` and stdout matches regexp:
"""
\* Introducing Extended Security Maintenance for Applications.
+Receive updates to over 30,000 software packages with your
+Ubuntu Advantage subscription. Free for personal use.
+https:\/\/ubuntu.com\/esm
\d+ update(s)? can be applied immediately.
\d+ of these updates (is|are) (a|an)? UA Infra: ESM security update(s)?.
(\d+ of these updates (is a|are) standard security update(s)?.)?
?To see these additional updates run: apt list --upgradable
"""
Then if `<release>` in `bionic` and stdout matches regexp:
"""
\* Introducing Extended Security Maintenance for Applications.
+Receive updates to over 30,000 software packages with your
+Ubuntu Advantage subscription. Free for personal use.
+https:\/\/ubuntu.com\/esm
\d+ update(s)? can be applied immediately.
\d+ of these updates (is a|are) standard security update(s)?.
To see these additional updates run: apt list --upgradable
"""
Then if `<release>` in `xenial` and stdout matches regexp:
"""
\* Introducing Extended Security Maintenance for Applications.
+Receive updates to over 30,000 software packages with your
+Ubuntu Advantage subscription. Free for personal use.
+https:\/\/ubuntu.com\/16-04
UA Infra: Extended Security Maintenance \(ESM\) is enabled.
\d+ update(s)? can be applied immediately.
\d+ of these updates (is|are) UA Infra: ESM security update(s)?.
\d+ of these updates (is a|are) standard security update(s)?.
To see these additional updates run: apt list --upgradable
"""
When I update contract to use `effectiveTo` as `days=-20`
And I delete the file `/var/lib/ubuntu-advantage/jobs-status.json`
And I run `python3 /usr/lib/ubuntu-advantage/timer.py` with sudo
And I run `update-motd` with sudo
Then if `<release>` in `xenial` and stdout matches regexp:
"""
\*Your UA Infra: ESM subscription has EXPIRED\*
\d+ additional security update\(s\) could have been applied via UA Infra: ESM.
Renew your UA services at https:\/\/ubuntu.com\/advantage
"""
Then if `<release>` in `xenial` and stdout matches regexp:
"""
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
"""
When I run `apt upgrade --dry-run` with sudo
Then if `<release>` in `xenial` and stdout matches regexp:
"""
\*Your UA Infra: ESM subscription has EXPIRED\*
Enabling UA Infra: ESM service would provide security updates for following packages:
.*
\d+ esm-infra security update\(s\) NOT APPLIED. Renew your UA services at
https:\/\/ubuntu.com\/advantage
"""
Examples: ubuntu release packages
| release | downrev_pkg | cc_status |
| xenial | libkrad0=1.13.2+dfsg-5 | disabled |
| bionic | libkrad0=1.16-2build1 | n/a |
| focal | hello=2.10-2ubuntu2 | n/a |
@series.all
@uses.config.machine_type.aws.generic
Scenario Outline: Attach command in an generic AWS Ubuntu VM
Given a `<release>` machine with ubuntu-advantage-tools installed
When I create the file `/tmp/machine-token-overlay.json` with the following:
"""
{
"machineTokenInfo": {
"contractInfo": {
"resourceEntitlements": [
{
"type": "esm-apps",
"entitled": false
}
]
}
}
}
"""
And I append the following on uaclient config:
"""
features:
machine_token_overlay: "/tmp/machine-token-overlay.json"
"""
And I attach `contract_token` with sudo
Then stdout matches regexp:
"""
UA Infra: ESM enabled
"""
And stdout matches regexp:
"""
This machine is now attached to
"""
And stdout matches regexp:
"""
SERVICE ENTITLED STATUS DESCRIPTION
cc-eal +yes +<cc_status> +Common Criteria EAL2 Provisioning Packages
cis +yes +disabled +Center for Internet Security Audit Tools
esm-infra +yes +enabled +UA Infra: Extended Security Maintenance \(ESM\)
fips +yes +<fips_status> +NIST-certified core packages
fips-updates +yes +<fips_status> +NIST-certified core packages with priority security updates
livepatch +yes +<lp_status> +<lp_desc>
"""
And stderr matches regexp:
"""
Enabling default service esm-infra
"""
Examples: ubuntu release livepatch status
| release | fips_status |lp_status | lp_desc | cc_status |
| xenial | disabled |enabled | Canonical Livepatch service | disabled |
| bionic | disabled |enabled | Canonical Livepatch service | n/a |
| focal | n/a |enabled | Canonical Livepatch service | n/a |
@series.all
@uses.config.machine_type.azure.generic
Scenario Outline: Attach command in an generic Azure Ubuntu VM
Given a `<release>` machine with ubuntu-advantage-tools installed
When I create the file `/tmp/machine-token-overlay.json` with the following:
"""
{
"machineTokenInfo": {
"contractInfo": {
"resourceEntitlements": [
{
"type": "esm-apps",
"entitled": false
}
]
}
}
}
"""
And I append the following on uaclient config:
"""
features:
machine_token_overlay: "/tmp/machine-token-overlay.json"
"""
And I attach `contract_token` with sudo
Then stdout matches regexp:
"""
UA Infra: ESM enabled
"""
And stdout matches regexp:
"""
This machine is now attached to
"""
And stdout matches regexp:
"""
SERVICE ENTITLED STATUS DESCRIPTION
cc-eal +yes +<cc_status> +Common Criteria EAL2 Provisioning Packages
cis +yes +disabled +Center for Internet Security Audit Tools
esm-infra +yes +enabled +UA Infra: Extended Security Maintenance \(ESM\)
fips +yes +<fips_status> +NIST-certified core packages
fips-updates +yes +<fips_status> +NIST-certified core packages with priority security updates
livepatch +yes +<lp_status> +Canonical Livepatch service
"""
And stderr matches regexp:
"""
Enabling default service esm-infra
"""
Examples: ubuntu release livepatch status
| release | lp_status | fips_status | cc_status |
| xenial | n/a | n/a | disabled |
| bionic | n/a | disabled | n/a |
| focal | enabled | n/a | n/a |
@series.all
@uses.config.machine_type.gcp.generic
Scenario Outline: Attach command in an generic GCP Ubuntu VM
Given a `<release>` machine with ubuntu-advantage-tools installed
When I create the file `/tmp/machine-token-overlay.json` with the following:
"""
{
"machineTokenInfo": {
"contractInfo": {
"resourceEntitlements": [
{
"type": "esm-apps",
"entitled": false
}
]
}
}
}
"""
And I append the following on uaclient config:
"""
features:
machine_token_overlay: "/tmp/machine-token-overlay.json"
"""
And I attach `contract_token` with sudo
Then stdout matches regexp:
"""
UA Infra: ESM enabled
"""
And stdout matches regexp:
"""
This machine is now attached to
"""
And stdout matches regexp:
"""
SERVICE ENTITLED STATUS DESCRIPTION
cc-eal +yes +<cc_status> +Common Criteria EAL2 Provisioning Packages
cis +yes +disabled +Center for Internet Security Audit Tools
esm-infra +yes +enabled +UA Infra: Extended Security Maintenance \(ESM\)
fips +yes +<fips_status> +NIST-certified core packages
fips-updates +yes +<fips_status> +NIST-certified core packages with priority security updates
livepatch +yes +<lp_status> +Canonical Livepatch service
"""
And stderr matches regexp:
"""
Enabling default service esm-infra
"""
Examples: ubuntu release livepatch status
| release | lp_status | fips_status | cc_status |
| xenial | n/a | n/a | disabled |
| bionic | n/a | disabled | n/a |
| focal | enabled | n/a | n/a |