-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kubernetes Roles Acceptance Tests #18360
Merged
kiannaquach
merged 1 commit into
ui/kubernetes-secrets-engine
from
ui/VAULT-12187/roles-acceptance-tests
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import ENV from 'vault/config/environment'; | ||
const { handler } = ENV['ember-cli-mirage']; | ||
import kubernetesScenario from './kubernetes'; | ||
|
||
export default function (server) { | ||
server.create('clients/config'); | ||
server.create('feature', { feature_flags: ['SOME_FLAG', 'VAULT_CLOUD_ADMIN_NAMESPACE'] }); | ||
|
||
if (handler === 'kubernetes') { | ||
server.create('kubernetes-config', { path: 'kubernetes' }); | ||
server.create('kubernetes-role'); | ||
server.create('kubernetes-role', 'withRoleName'); | ||
server.create('kubernetes-role', 'withRoleRules'); | ||
kubernetesScenario(server); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default function (server) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for putting this in its own file! |
||
server.create('kubernetes-config', { path: 'kubernetes' }); | ||
server.create('kubernetes-role'); | ||
server.create('kubernetes-role', 'withRoleName'); | ||
server.create('kubernetes-role', 'withRoleRules'); | ||
} |
123 changes: 123 additions & 0 deletions
123
ui/tests/acceptance/secrets/backend/kubernetes/roles-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { setupMirage } from 'ember-cli-mirage/test-support'; | ||
import kubernetesScenario from 'vault/mirage/scenarios/kubernetes'; | ||
import ENV from 'vault/config/environment'; | ||
import authPage from 'vault/tests/pages/auth'; | ||
import { fillIn, visit, currentURL, click, currentRouteName } from '@ember/test-helpers'; | ||
|
||
module('Acceptance | kubernetes | roles', function (hooks) { | ||
setupApplicationTest(hooks); | ||
setupMirage(hooks); | ||
|
||
hooks.before(function () { | ||
ENV['ember-cli-mirage'].handler = 'kubernetes'; | ||
}); | ||
hooks.beforeEach(function () { | ||
kubernetesScenario(this.server); | ||
this.visitRoles = () => { | ||
return visit('/vault/secrets/kubernetes/kubernetes/roles'); | ||
}; | ||
this.validateRoute = (assert, route, message) => { | ||
assert.strictEqual(currentRouteName(), `vault.cluster.secrets.backend.kubernetes.${route}`, message); | ||
}; | ||
return authPage.login(); | ||
}); | ||
hooks.after(function () { | ||
ENV['ember-cli-mirage'].handler = null; | ||
}); | ||
|
||
test('it should filter roles', async function (assert) { | ||
await this.visitRoles(); | ||
assert.dom('[data-test-list-item-link]').exists({ count: 3 }, 'Roles list renders'); | ||
await fillIn('[data-test-comoponent="navigate-input"]', '1'); | ||
assert.dom('[data-test-list-item-link]').exists({ count: 1 }, 'Filtered roles list renders'); | ||
assert.ok(currentURL().includes('pageFilter=1'), 'pageFilter query param value is set'); | ||
}); | ||
|
||
test('it should link to role details on list item click', async function (assert) { | ||
assert.expect(1); | ||
await this.visitRoles(); | ||
await click('[data-test-list-item-link]'); | ||
this.validateRoute(assert, 'roles.role.details', 'Transitions to details route on list item click'); | ||
}); | ||
|
||
test('it should have correct breadcrumb links in role details view', async function (assert) { | ||
assert.expect(2); | ||
await this.visitRoles(); | ||
await click('[data-test-list-item-link]'); | ||
await click('[data-test-crumb="roles"] a'); | ||
this.validateRoute(assert, 'roles.index', 'Transitions to roles route on breadcrumb click'); | ||
await click('[data-test-list-item-link]'); | ||
await click('[data-test-crumb="overview"] a'); | ||
this.validateRoute(assert, 'overview', 'Transitions to overview route on breadcrumb click'); | ||
}); | ||
|
||
test('it should have functional list item menu', async function (assert) { | ||
assert.expect(3); | ||
await this.visitRoles(); | ||
for (const action of ['details', 'edit', 'delete']) { | ||
await click('[data-test-list-item-popup] button'); | ||
await click(`[data-test-${action}]`); | ||
if (action === 'delete') { | ||
await click('[data-test-confirm-button]'); | ||
assert.dom('[data-test-list-item-link]').exists({ count: 2 }, 'Deleted role removed from list'); | ||
} else { | ||
this.validateRoute( | ||
assert, | ||
`roles.role.${action}`, | ||
`Transitions to ${action} route on menu action click` | ||
); | ||
const selector = action === 'details' ? '[data-test-crumb="roles"] a' : '[data-test-cancel]'; | ||
await click(selector); | ||
} | ||
} | ||
}); | ||
|
||
test('it should create role', async function (assert) { | ||
assert.expect(2); | ||
await this.visitRoles(); | ||
await click('[data-test-toolbar-roles-action]'); | ||
await click('[data-test-radio-card="basic"]'); | ||
await fillIn('[data-test-input="name"]', 'new-test-role'); | ||
await fillIn('[data-test-input="serviceAccountName"]', 'default'); | ||
await fillIn('[data-test-input="allowedKubernetesNamespaces"]', '*'); | ||
await click('[data-test-save]'); | ||
this.validateRoute(assert, 'roles.role.details', 'Transitions to details route on save success'); | ||
await click('[data-test-crumb="roles"] a'); | ||
assert.dom('[data-test-role="new-test-role"]').exists('New role renders in list'); | ||
}); | ||
|
||
test('it should have functional toolbar actions in details view', async function (assert) { | ||
assert.expect(3); | ||
await this.visitRoles(); | ||
await click('[data-test-list-item-link]'); | ||
await click('[data-test-generate-credentials]'); | ||
this.validateRoute(assert, 'roles.role.credentials', 'Transitions to credentials route'); | ||
await click('[data-test-crumb="details"] a'); | ||
await click('[data-test-edit]'); | ||
this.validateRoute(assert, 'roles.role.edit', 'Transitions to edit route'); | ||
await click('[data-test-cancel]'); | ||
await click('[data-test-list-item-link]'); | ||
await click('[data-test-delete] button'); | ||
await click('[data-test-confirm-button]'); | ||
assert | ||
.dom('[data-test-list-item-link]') | ||
.exists({ count: 2 }, 'Transitions to roles route and deleted role removed from list'); | ||
}); | ||
|
||
test('it should generate credentials for role', async function (assert) { | ||
assert.expect(1); | ||
await this.visitRoles(); | ||
await click('[data-test-list-item-link]'); | ||
await click('[data-test-generate-credentials]'); | ||
await fillIn('[data-test-kubernetes-namespace]', 'test-namespace'); | ||
await click('[data-test-generate-credentials-button]'); | ||
await click('[data-test-generate-credentials-done]'); | ||
this.validateRoute( | ||
assert, | ||
'roles.role.details', | ||
'Transitions to details route when done generating credentials' | ||
); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉