mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 11:37: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>
113 lines
4.1 KiB
JavaScript
113 lines
4.1 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 } from '@ember/test-helpers';
|
|
import { typeInSearch, clickTrigger, selectChoose } from 'ember-power-select/test-support/helpers';
|
|
import { SELECTORS } from 'vault/tests/helpers/kubernetes/overview';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
module('Integration | Component | kubernetes | Page::Overview', 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.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.breadcrumbs = [
|
|
{ label: 'secrets', route: 'secrets', linkExternal: true },
|
|
{ label: this.backend.id },
|
|
];
|
|
this.promptConfig = false;
|
|
this.renderComponent = () => {
|
|
return render(
|
|
hbs`<Page::Overview @promptConfig={{this.promptConfig}} @backend={{this.backend}} @roles={{this.roles}} @breadcrumbs={{this.breadcrumbs}} />`,
|
|
{ owner: this.engine }
|
|
);
|
|
};
|
|
});
|
|
|
|
test('it should display role card', async function (assert) {
|
|
await this.renderComponent();
|
|
assert.dom(SELECTORS.rolesCardTitle).hasText('Roles');
|
|
assert
|
|
.dom(SELECTORS.rolesCardSubTitle)
|
|
.hasText('The number of Vault roles being used to generate Kubernetes credentials.');
|
|
assert.dom(SELECTORS.rolesCardLink).hasText('View Roles');
|
|
|
|
this.roles = [];
|
|
|
|
await this.renderComponent();
|
|
assert.dom(SELECTORS.rolesCardLink).hasText('Create Role');
|
|
});
|
|
|
|
test('it should display correct number of roles in role card', async function (assert) {
|
|
await this.renderComponent();
|
|
assert.dom(SELECTORS.rolesCardNumRoles).hasText('2');
|
|
|
|
this.roles = [];
|
|
|
|
await this.renderComponent();
|
|
|
|
assert.dom(SELECTORS.rolesCardNumRoles).hasText('None');
|
|
});
|
|
|
|
test('it should display generate credentials card', async function (assert) {
|
|
await this.renderComponent();
|
|
|
|
assert.dom(SELECTORS.generateCredentialsCardTitle).hasText('Generate credentials');
|
|
assert
|
|
.dom(SELECTORS.generateCredentialsCardSubTitle)
|
|
.hasText('Quickly generate credentials by typing the role name.');
|
|
});
|
|
|
|
test('it should show options for SearchSelect', async function (assert) {
|
|
await this.renderComponent();
|
|
await clickTrigger();
|
|
assert.strictEqual(this.element.querySelectorAll('.ember-power-select-option').length, 2);
|
|
await typeInSearch('role-0');
|
|
assert.strictEqual(this.element.querySelectorAll('.ember-power-select-option').length, 1);
|
|
assert.dom(SELECTORS.generateCredentialsCardButton).isDisabled();
|
|
await selectChoose('', '.ember-power-select-option', 2);
|
|
assert.dom(SELECTORS.generateCredentialsCardButton).isNotDisabled();
|
|
});
|
|
|
|
test('it should show ConfigCta when no config is set up', async function (assert) {
|
|
this.promptConfig = true;
|
|
|
|
await this.renderComponent();
|
|
assert.dom(SELECTORS.emptyStateTitle).hasText('Kubernetes not configured');
|
|
assert
|
|
.dom(SELECTORS.emptyStateMessage)
|
|
.hasText(
|
|
'Get started by establishing the URL of the Kubernetes API to connect to, along with some additional options.'
|
|
);
|
|
assert.dom(SELECTORS.emptyStateActionText).hasText('Configure Kubernetes');
|
|
});
|
|
});
|