mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 02:57:04 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
108 lines
4.2 KiB
JavaScript
108 lines
4.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import { render, click } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
module('Integration | Component | kubernetes | Page::Roles', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'kubernetes');
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.store.pushPayload('secret-engine', {
|
|
modelName: 'secret-engine',
|
|
data: {
|
|
accessor: 'kubernetes_f3400dee',
|
|
path: 'kubernetes-test/',
|
|
type: 'kubernetes',
|
|
},
|
|
});
|
|
this.store.pushPayload('kubernetes/role', {
|
|
modelName: 'kubernetes/role',
|
|
backend: 'kubernetes-test',
|
|
...this.server.create('kubernetes-role'),
|
|
});
|
|
this.backend = this.store.peekRecord('secret-engine', 'kubernetes-test');
|
|
this.roles = this.store.peekAll('kubernetes/role');
|
|
this.filterValue = '';
|
|
this.breadcrumbs = [
|
|
{ label: 'secrets', route: 'secrets', linkExternal: true },
|
|
{ label: this.backend.id },
|
|
];
|
|
this.promptConfig = false;
|
|
|
|
this.renderComponent = () => {
|
|
return render(
|
|
hbs`<Page::Roles @promptConfig={{this.promptConfig}} @backend={{this.backend}} @roles={{this.roles}} @filterValue={{this.filterValue}} @breadcrumbs={{this.breadcrumbs}} />`,
|
|
{ owner: this.engine }
|
|
);
|
|
};
|
|
});
|
|
|
|
test('it should render tab page header and config cta', async function (assert) {
|
|
this.promptConfig = true;
|
|
await this.renderComponent();
|
|
assert.dom('.title svg').hasClass('flight-icon-kubernetes', 'Kubernetes icon renders in title');
|
|
assert.dom('.title').hasText('kubernetes-test', 'Mount path renders in title');
|
|
assert
|
|
.dom('[data-test-toolbar-roles-action]')
|
|
.doesNotExist('Create role', 'Toolbar action does not render when not configured');
|
|
assert
|
|
.dom('[data-test-nav-input]')
|
|
.doesNotExist('Roles filter input does not render when not configured');
|
|
assert.dom('[data-test-config-cta]').exists('Config cta renders');
|
|
});
|
|
|
|
test('it should render create roles cta', async function (assert) {
|
|
this.roles = null;
|
|
await this.renderComponent();
|
|
assert.dom('[data-test-toolbar-roles-action]').hasText('Create role', 'Toolbar action has correct text');
|
|
assert
|
|
.dom('[data-test-toolbar-roles-action] svg')
|
|
.hasClass('flight-icon-plus', 'Toolbar action has correct icon');
|
|
assert.dom('[data-test-nav-input]').exists('Roles filter input renders');
|
|
assert.dom('[data-test-empty-state-title]').hasText('No roles yet', 'Title renders');
|
|
assert
|
|
.dom('[data-test-empty-state-message]')
|
|
.hasText(
|
|
'When created, roles will be listed here. Create a role to start generating service account tokens.',
|
|
'Message renders'
|
|
);
|
|
assert.dom('[data-test-empty-state-actions] a').hasText('Create role', 'Action renders');
|
|
});
|
|
|
|
test('it should render no matches filter message', async function (assert) {
|
|
this.roles = [];
|
|
this.filterValue = 'test';
|
|
await this.renderComponent();
|
|
assert
|
|
.dom('[data-test-empty-state-title]')
|
|
.hasText('There are no roles matching "test"', 'Filter message renders');
|
|
});
|
|
|
|
test('it should render roles list', async function (assert) {
|
|
this.server.post('/sys/capabilities-self', () => ({
|
|
data: {
|
|
'kubernetes/role': ['root'],
|
|
},
|
|
}));
|
|
await this.renderComponent();
|
|
assert.dom('[data-test-list-item-content] svg').hasClass('flight-icon-user', 'List item icon renders');
|
|
assert
|
|
.dom('[data-test-list-item-content]')
|
|
.hasText(this.roles.firstObject.name, 'List item name renders');
|
|
await click('[data-test-popup-menu-trigger]');
|
|
assert.dom('[data-test-details]').hasText('Details', 'Details link renders in menu');
|
|
assert.dom('[data-test-edit]').hasText('Edit', 'Edit link renders in menu');
|
|
assert.dom('[data-test-delete]').hasText('Delete', 'Details link renders in menu');
|
|
});
|
|
});
|