mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +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>
109 lines
4.0 KiB
JavaScript
109 lines
4.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import sinon from 'sinon';
|
|
import EmberObject from '@ember/object';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import timestamp from 'core/utils/timestamp';
|
|
|
|
module('Integration | Component | keymgmt/key-edit', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.before(function () {
|
|
sinon.stub(timestamp, 'now').callsFake(() => new Date('2018-04-03T14:15:30'));
|
|
});
|
|
hooks.beforeEach(function () {
|
|
const now = timestamp.now();
|
|
const model = EmberObject.create({
|
|
name: 'Unicorns',
|
|
id: 'Unicorns',
|
|
minEnabledVersion: 1,
|
|
versions: [
|
|
{
|
|
id: 1,
|
|
creation_time: now.toString(),
|
|
},
|
|
{
|
|
id: 2,
|
|
creation_time: now.toString(),
|
|
},
|
|
],
|
|
canDelete: true,
|
|
});
|
|
this.model = model;
|
|
this.tab = '';
|
|
});
|
|
hooks.after(function () {
|
|
timestamp.now.restore();
|
|
});
|
|
|
|
// TODO: Add capabilities tests
|
|
test('it renders show view as default', async function (assert) {
|
|
assert.expect(8);
|
|
await render(
|
|
hbs`<Keymgmt::KeyEdit @model={{this.model}} @tab={{this.tab}} /><div id="modal-wormhole" />`
|
|
);
|
|
assert.dom('[data-test-secret-header]').hasText('Unicorns', 'Shows key name');
|
|
assert.dom('[data-test-keymgmt-key-toolbar]').exists('Subnav toolbar exists');
|
|
assert.dom('[data-test-tab="Details"]').exists('Details tab exists');
|
|
assert.dom('[data-test-tab="Versions"]').exists('Versions tab exists');
|
|
assert.dom('[data-test-keymgmt-key-destroy]').isDisabled('Destroy button is disabled');
|
|
assert.dom('[data-test-keymgmt-dist-empty-state]').exists('Distribution empty state exists');
|
|
|
|
this.set('tab', 'versions');
|
|
assert.dom('[data-test-keymgmt-key-version]').exists({ count: 2 }, 'Renders two version list items');
|
|
assert
|
|
.dom('[data-test-keymgmt-key-current-min]')
|
|
.exists({ count: 1 }, 'Checks only one as current minimum');
|
|
});
|
|
|
|
test('it renders the correct elements on edit view', async function (assert) {
|
|
assert.expect(4);
|
|
const model = EmberObject.create({
|
|
name: 'Unicorns',
|
|
id: 'Unicorns',
|
|
});
|
|
this.set('mode', 'edit');
|
|
this.set('model', model);
|
|
|
|
await render(
|
|
hbs`<Keymgmt::KeyEdit @model={{this.model}} @mode={{this.mode}} /><div id="modal-wormhole" />`
|
|
);
|
|
assert.dom('[data-test-secret-header]').hasText('Edit Key', 'Shows edit header');
|
|
assert.dom('[data-test-keymgmt-key-toolbar]').doesNotExist('Subnav toolbar does not exist');
|
|
assert.dom('[data-test-tab="Details"]').doesNotExist('Details tab does not exist');
|
|
assert.dom('[data-test-tab="Versions"]').doesNotExist('Versions tab does not exist');
|
|
});
|
|
|
|
test('it renders the correct elements on create view', async function (assert) {
|
|
assert.expect(4);
|
|
const model = EmberObject.create({});
|
|
this.set('mode', 'create');
|
|
this.set('model', model);
|
|
|
|
await render(
|
|
hbs`<Keymgmt::KeyEdit @model={{this.model}} @mode={{this.mode}} /><div id="modal-wormhole" />`
|
|
);
|
|
assert.dom('[data-test-secret-header]').hasText('Create Key', 'Shows edit header');
|
|
assert.dom('[data-test-keymgmt-key-toolbar]').doesNotExist('Subnav toolbar does not exist');
|
|
assert.dom('[data-test-tab="Details"]').doesNotExist('Details tab does not exist');
|
|
assert.dom('[data-test-tab="Versions"]').doesNotExist('Versions tab does not exist');
|
|
});
|
|
|
|
test('it defaults to keyType rsa-2048', async function (assert) {
|
|
assert.expect(1);
|
|
const store = this.owner.lookup('service:store');
|
|
this.model = store.createRecord('keymgmt/key');
|
|
this.set('mode', 'create');
|
|
await render(
|
|
hbs`<Keymgmt::KeyEdit @model={{this.model}} @mode={{this.mode}} /><div id="modal-wormhole" />`
|
|
);
|
|
assert.dom('[data-test-input="type"]').hasValue('rsa-2048', 'Has type rsa-2048 by default');
|
|
});
|
|
});
|