@@ -13,7 +13,7 @@ import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
13
13
import { click , currentURL , fillIn , find , isSettled , visit } from '@ember/test-helpers' ;
14
14
import { SELECTORS } from 'vault/tests/helpers/pki/workflow' ;
15
15
import { adminPolicy , readerPolicy , updatePolicy } from 'vault/tests/helpers/policy-generator/pki' ;
16
- import { tokenWithPolicy , runCommands } from 'vault/tests/helpers/pki/pki-run-commands' ;
16
+ import { tokenWithPolicy , runCommands , clearRecords } from 'vault/tests/helpers/pki/pki-run-commands' ;
17
17
import { unsupportedPem } from 'vault/tests/helpers/pki/values' ;
18
18
19
19
/**
@@ -25,12 +25,14 @@ module('Acceptance | pki workflow', function (hooks) {
25
25
setupApplicationTest ( hooks ) ;
26
26
27
27
hooks . beforeEach ( async function ( ) {
28
+ this . store = this . owner . lookup ( 'service:store' ) ;
28
29
await authPage . login ( ) ;
29
30
// Setup PKI engine
30
31
const mountPath = `pki-workflow-${ uuidv4 ( ) } ` ;
31
32
await enablePage . enable ( 'pki' , mountPath ) ;
32
33
this . mountPath = mountPath ;
33
34
await logout . visit ( ) ;
35
+ clearRecords ( this . store ) ;
34
36
} ) ;
35
37
36
38
hooks . afterEach ( async function ( ) {
@@ -40,40 +42,50 @@ module('Acceptance | pki workflow', function (hooks) {
40
42
await runCommands ( [ `delete sys/mounts/${ this . mountPath } ` ] ) ;
41
43
} ) ;
42
44
43
- test ( 'empty state messages are correct when PKI not configured' , async function ( assert ) {
44
- assert . expect ( 21 ) ;
45
- const assertEmptyState = ( assert , resource ) => {
46
- assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/${ resource } ` ) ;
47
- assert
48
- . dom ( SELECTORS . emptyStateTitle )
49
- . hasText (
50
- 'PKI not configured' ,
51
- `${ resource } index renders correct empty state title when PKI not configured`
52
- ) ;
53
- assert . dom ( SELECTORS . emptyStateLink ) . hasText ( 'Configure PKI' ) ;
54
- assert
55
- . dom ( SELECTORS . emptyStateMessage )
56
- . hasText (
57
- `This PKI mount hasn't yet been configured with a certificate issuer.` ,
58
- `${ resource } index empty state message correct when PKI not configured`
59
- ) ;
60
- } ;
61
- await authPage . login ( this . pkiAdminToken ) ;
62
- await visit ( `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
63
- assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
64
-
65
- await click ( SELECTORS . rolesTab ) ;
66
- assertEmptyState ( assert , 'roles' ) ;
67
-
68
- await click ( SELECTORS . issuersTab ) ;
69
- assertEmptyState ( assert , 'issuers' ) ;
70
-
71
- await click ( SELECTORS . certsTab ) ;
72
- assertEmptyState ( assert , 'certificates' ) ;
73
- await click ( SELECTORS . keysTab ) ;
74
- assertEmptyState ( assert , 'keys' ) ;
75
- await click ( SELECTORS . tidyTab ) ;
76
- assertEmptyState ( assert , 'tidy' ) ;
45
+ module ( 'not configured' , function ( hooks ) {
46
+ hooks . beforeEach ( async function ( ) {
47
+ await authPage . login ( ) ;
48
+ const pki_admin_policy = adminPolicy ( this . mountPath , 'roles' ) ;
49
+ this . pkiAdminToken = await tokenWithPolicy ( `pki-admin-${ this . mountPath } ` , pki_admin_policy ) ;
50
+ await logout . visit ( ) ;
51
+ clearRecords ( this . store ) ;
52
+ } ) ;
53
+
54
+ test ( 'empty state messages are correct when PKI not configured' , async function ( assert ) {
55
+ assert . expect ( 21 ) ;
56
+ const assertEmptyState = ( assert , resource ) => {
57
+ assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/${ resource } ` ) ;
58
+ assert
59
+ . dom ( SELECTORS . emptyStateTitle )
60
+ . hasText (
61
+ 'PKI not configured' ,
62
+ `${ resource } index renders correct empty state title when PKI not configured`
63
+ ) ;
64
+ assert . dom ( SELECTORS . emptyStateLink ) . hasText ( 'Configure PKI' ) ;
65
+ assert
66
+ . dom ( SELECTORS . emptyStateMessage )
67
+ . hasText (
68
+ `This PKI mount hasn't yet been configured with a certificate issuer.` ,
69
+ `${ resource } index empty state message correct when PKI not configured`
70
+ ) ;
71
+ } ;
72
+ await authPage . login ( this . pkiAdminToken ) ;
73
+ await visit ( `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
74
+ assert . strictEqual ( currentURL ( ) , `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
75
+
76
+ await click ( SELECTORS . rolesTab ) ;
77
+ assertEmptyState ( assert , 'roles' ) ;
78
+
79
+ await click ( SELECTORS . issuersTab ) ;
80
+ assertEmptyState ( assert , 'issuers' ) ;
81
+
82
+ await click ( SELECTORS . certsTab ) ;
83
+ assertEmptyState ( assert , 'certificates' ) ;
84
+ await click ( SELECTORS . keysTab ) ;
85
+ assertEmptyState ( assert , 'keys' ) ;
86
+ await click ( SELECTORS . tidyTab ) ;
87
+ assertEmptyState ( assert , 'tidy' ) ;
88
+ } ) ;
77
89
} ) ;
78
90
79
91
module ( 'roles' , function ( hooks ) {
@@ -91,10 +103,11 @@ module('Acceptance | pki workflow', function (hooks) {
91
103
const pki_admin_policy = adminPolicy ( this . mountPath , 'roles' ) ;
92
104
const pki_reader_policy = readerPolicy ( this . mountPath , 'roles' ) ;
93
105
const pki_editor_policy = updatePolicy ( this . mountPath , 'roles' ) ;
94
- this . pkiRoleReader = await tokenWithPolicy ( ' pki-reader' , pki_reader_policy ) ;
95
- this . pkiRoleEditor = await tokenWithPolicy ( ' pki-editor' , pki_editor_policy ) ;
96
- this . pkiAdminToken = await tokenWithPolicy ( ' pki-admin' , pki_admin_policy ) ;
106
+ this . pkiRoleReader = await tokenWithPolicy ( ` pki-reader- ${ this . mountPath } ` , pki_reader_policy ) ;
107
+ this . pkiRoleEditor = await tokenWithPolicy ( ` pki-editor- ${ this . mountPath } ` , pki_editor_policy ) ;
108
+ this . pkiAdminToken = await tokenWithPolicy ( ` pki-admin- ${ this . mountPath } ` , pki_admin_policy ) ;
97
109
await logout . visit ( ) ;
110
+ clearRecords ( this . store ) ;
98
111
} ) ;
99
112
100
113
test ( 'shows correct items if user has all permissions' , async function ( assert ) {
@@ -222,10 +235,11 @@ module('Acceptance | pki workflow', function (hooks) {
222
235
const pki_admin_policy = adminPolicy ( this . mountPath ) ;
223
236
const pki_reader_policy = readerPolicy ( this . mountPath , 'keys' , true ) ;
224
237
const pki_editor_policy = updatePolicy ( this . mountPath , 'keys' ) ;
225
- this . pkiKeyReader = await tokenWithPolicy ( ' pki-reader' , pki_reader_policy ) ;
226
- this . pkiKeyEditor = await tokenWithPolicy ( ' pki-editor' , pki_editor_policy ) ;
227
- this . pkiAdminToken = await tokenWithPolicy ( ' pki-admin' , pki_admin_policy ) ;
238
+ this . pkiKeyReader = await tokenWithPolicy ( ` pki-reader- ${ this . mountPath } ` , pki_reader_policy ) ;
239
+ this . pkiKeyEditor = await tokenWithPolicy ( ` pki-editor- ${ this . mountPath } ` , pki_editor_policy ) ;
240
+ this . pkiAdminToken = await tokenWithPolicy ( ` pki-admin- ${ this . mountPath } ` , pki_admin_policy ) ;
228
241
await logout . visit ( ) ;
242
+ clearRecords ( this . store ) ;
229
243
} ) ;
230
244
231
245
test ( 'shows correct items if user has all permissions' , async function ( assert ) {
@@ -339,11 +353,14 @@ module('Acceptance | pki workflow', function (hooks) {
339
353
module ( 'issuers' , function ( hooks ) {
340
354
hooks . beforeEach ( async function ( ) {
341
355
await authPage . login ( ) ;
356
+ const pki_admin_policy = adminPolicy ( this . mountPath ) ;
357
+ this . pkiAdminToken = await tokenWithPolicy ( `pki-admin-${ this . mountPath } ` , pki_admin_policy ) ;
342
358
// Configure engine with a default issuer
343
359
await runCommands ( [
344
360
`write ${ this . mountPath } /root/generate/internal common_name="Hashicorp Test" name="Hashicorp Test"` ,
345
361
] ) ;
346
362
await logout . visit ( ) ;
363
+ clearRecords ( this . store ) ;
347
364
} ) ;
348
365
test ( 'lists the correct issuer metadata info' , async function ( assert ) {
349
366
assert . expect ( 6 ) ;
@@ -373,7 +390,10 @@ module('Acceptance | pki workflow', function (hooks) {
373
390
capabilities = ["deny"]
374
391
}
375
392
` ;
376
- this . token = await tokenWithPolicy ( 'pki-issuer-denied-policy' , pki_issuer_denied_policy ) ;
393
+ this . token = await tokenWithPolicy (
394
+ `pki-issuer-denied-policy-${ this . mountPath } ` ,
395
+ pki_issuer_denied_policy
396
+ ) ;
377
397
await logout . visit ( ) ;
378
398
await authPage . login ( this . token ) ;
379
399
await visit ( `/vault/secrets/${ this . mountPath } /pki/overview` ) ;
@@ -487,7 +507,10 @@ module('Acceptance | pki workflow', function (hooks) {
487
507
${ adminPolicy ( this . mountPath ) }
488
508
${ readerPolicy ( this . mountPath , 'config/cluster' ) }
489
509
` ;
490
- this . mixedConfigCapabilities = await tokenWithPolicy ( 'pki-reader' , mixed_config_policy ) ;
510
+ this . mixedConfigCapabilities = await tokenWithPolicy (
511
+ `pki-reader-${ this . mountPath } ` ,
512
+ mixed_config_policy
513
+ ) ;
491
514
await logout . visit ( ) ;
492
515
} ) ;
493
516
0 commit comments