@@ -40,43 +40,53 @@ module('Acceptance | pki workflow', function (hooks) {
40
40
await logout . visit ( ) ;
41
41
await authPage . login ( ) ;
42
42
// Cleanup engine
43
- await runCmd ( `delete sys/mounts/${ this . mountPath } ` , false ) ;
43
+ await runCommands ( [ `delete sys/mounts/${ this . mountPath } ` ] ) ;
44
44
} ) ;
45
45
46
- test ( 'empty state messages are correct when PKI not configured' , async function ( assert ) {
47
- assert . expect ( 21 ) ;
48
- const assertEmptyState = ( assert , resource ) => {
49
- assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/${ resource } ` ) ;
50
- assert
51
- . dom ( SELECTORS . emptyStateTitle )
52
- . hasText (
53
- 'PKI not configured' ,
54
- `${ resource } index renders correct empty state title when PKI not configured`
55
- ) ;
56
- assert . dom ( SELECTORS . emptyStateLink ) . hasText ( 'Configure PKI' ) ;
57
- assert
58
- . dom ( SELECTORS . emptyStateMessage )
59
- . hasText (
60
- `This PKI mount hasn't yet been configured with a certificate issuer.` ,
61
- `${ resource } index empty state message correct when PKI not configured`
62
- ) ;
63
- } ;
64
- await authPage . login ( this . pkiAdminToken ) ;
65
- await visit ( `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
66
- assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
67
-
68
- await click ( SELECTORS . rolesTab ) ;
69
- assertEmptyState ( assert , 'roles' ) ;
70
-
71
- await click ( SELECTORS . issuersTab ) ;
72
- assertEmptyState ( assert , 'issuers' ) ;
73
-
74
- await click ( SELECTORS . certsTab ) ;
75
- assertEmptyState ( assert , 'certificates' ) ;
76
- await click ( SELECTORS . keysTab ) ;
77
- assertEmptyState ( assert , 'keys' ) ;
78
- await click ( SELECTORS . tidyTab ) ;
79
- assertEmptyState ( assert , 'tidy' ) ;
46
+ module ( 'not configured' , function ( hooks ) {
47
+ hooks . beforeEach ( async function ( ) {
48
+ await authPage . login ( ) ;
49
+ const pki_admin_policy = adminPolicy ( this . mountPath , 'roles' ) ;
50
+ this . pkiAdminToken = await tokenWithPolicy ( `pki-admin-${ this . mountPath } ` , pki_admin_policy ) ;
51
+ await logout . visit ( ) ;
52
+ clearPkiRecords ( this . store ) ;
53
+ } ) ;
54
+
55
+ test ( 'empty state messages are correct when PKI not configured' , async function ( assert ) {
56
+ assert . expect ( 21 ) ;
57
+ const assertEmptyState = ( assert , resource ) => {
58
+ assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/${ resource } ` ) ;
59
+ assert
60
+ . dom ( SELECTORS . emptyStateTitle )
61
+ . hasText (
62
+ 'PKI not configured' ,
63
+ `${ resource } index renders correct empty state title when PKI not configured`
64
+ ) ;
65
+ assert . dom ( SELECTORS . emptyStateLink ) . hasText ( 'Configure PKI' ) ;
66
+ assert
67
+ . dom ( SELECTORS . emptyStateMessage )
68
+ . hasText (
69
+ `This PKI mount hasn't yet been configured with a certificate issuer.` ,
70
+ `${ resource } index empty state message correct when PKI not configured`
71
+ ) ;
72
+ } ;
73
+ await authPage . login ( this . pkiAdminToken ) ;
74
+ await visit ( `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
75
+ assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
76
+
77
+ await click ( SELECTORS . rolesTab ) ;
78
+ assertEmptyState ( assert , 'roles' ) ;
79
+
80
+ await click ( SELECTORS . issuersTab ) ;
81
+ assertEmptyState ( assert , 'issuers' ) ;
82
+
83
+ await click ( SELECTORS . certsTab ) ;
84
+ assertEmptyState ( assert , 'certificates' ) ;
85
+ await click ( SELECTORS . keysTab ) ;
86
+ assertEmptyState ( assert , 'keys' ) ;
87
+ await click ( SELECTORS . tidyTab ) ;
88
+ assertEmptyState ( assert , 'tidy' ) ;
89
+ } ) ;
80
90
} ) ;
81
91
82
92
module ( 'roles' , function ( hooks ) {
@@ -231,10 +241,11 @@ module('Acceptance | pki workflow', function (hooks) {
231
241
const pki_admin_policy = adminPolicy ( this . mountPath ) ;
232
242
const pki_reader_policy = readerPolicy ( this . mountPath , 'keys' , true ) ;
233
243
const pki_editor_policy = updatePolicy ( this . mountPath , 'keys' ) ;
234
- this . pkiKeyReader = await runCmd ( tokenWithPolicyCmd ( ' pki-reader' , pki_reader_policy ) ) ;
235
- this . pkiKeyEditor = await runCmd ( tokenWithPolicyCmd ( ' pki-editor' , pki_editor_policy ) ) ;
236
- this . pkiAdminToken = await runCmd ( tokenWithPolicyCmd ( ' pki-admin' , pki_admin_policy ) ) ;
244
+ this . pkiKeyReader = await tokenWithPolicy ( ` pki-reader- ${ this . mountPath } ` , pki_reader_policy ) ;
245
+ this . pkiKeyEditor = await tokenWithPolicy ( ` pki-editor- ${ this . mountPath } ` , pki_editor_policy ) ;
246
+ this . pkiAdminToken = await tokenWithPolicy ( ` pki-admin- ${ this . mountPath } ` , pki_admin_policy ) ;
237
247
await logout . visit ( ) ;
248
+ clearPkiRecords ( this . store ) ;
238
249
} ) ;
239
250
240
251
test ( 'shows correct items if user has all permissions' , async function ( assert ) {
@@ -349,9 +360,12 @@ module('Acceptance | pki workflow', function (hooks) {
349
360
module ( 'issuers' , function ( hooks ) {
350
361
hooks . beforeEach ( async function ( ) {
351
362
await authPage . login ( ) ;
363
+ const pki_admin_policy = adminPolicy ( this . mountPath ) ;
364
+ this . pkiAdminToken = await tokenWithPolicy ( `pki-admin-${ this . mountPath } ` , pki_admin_policy ) ;
352
365
// Configure engine with a default issuer
353
366
await configureEngine ( this . mountPath , 'common_name="Hashicorp Test" issuer_name="hashicorp_test"' ) ;
354
367
await logout . visit ( ) ;
368
+ clearPkiRecords ( this . store ) ;
355
369
} ) ;
356
370
test ( 'lists the correct issuer metadata info' , async function ( assert ) {
357
371
assert . expect ( 8 ) ;
0 commit comments