mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02:00
* wip * work in progress * pki-role-form-test * clean up * radio-select-ttl-or-string test * clean up * add yielded check * 12 to 13 * add pki-key-usage test * remove meep * key-params test * clean up * clean up * pr comments
102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render, click, fillIn } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import { SELECTORS } from 'vault/tests/helpers/pki-engine';
|
|
|
|
module('Integration | Component | pki-key-parameters', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'pki');
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.model = this.store.createRecord('pki/pki-role-engine');
|
|
this.model.backend = 'pki';
|
|
});
|
|
|
|
test('it should render the component and display the correct defaults', async function (assert) {
|
|
assert.expect(3);
|
|
await render(
|
|
hbs`
|
|
<div class="has-top-margin-xxl">
|
|
<PkiKeyParameters
|
|
@model={{this.model}}
|
|
@group="Key parameters"
|
|
/>
|
|
</div>
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
await click(SELECTORS.keyParams);
|
|
assert.dom(SELECTORS.keyType).hasValue('rsa');
|
|
assert.dom(SELECTORS.keyBits).hasValue('2048');
|
|
assert.dom(SELECTORS.signatureBits).hasValue('0');
|
|
});
|
|
|
|
test('it should set the model properties of key_type and key_bits when key_type changes', async function (assert) {
|
|
assert.expect(11);
|
|
await render(
|
|
hbs`
|
|
<div class="has-top-margin-xxl">
|
|
<PkiKeyParameters
|
|
@model={{this.model}}
|
|
@group="Key parameters"
|
|
/>
|
|
</div>
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
assert.strictEqual(this.model.keyType, 'rsa', 'sets the default value for key_type on the model.');
|
|
assert.strictEqual(this.model.keyBits, 2048, 'sets the default value for key_bits on the model.');
|
|
assert.strictEqual(
|
|
this.model.signatureBits,
|
|
0,
|
|
'sets the default value for signature_bits on the model.'
|
|
);
|
|
await click(SELECTORS.keyParams);
|
|
await fillIn(SELECTORS.keyType, 'ec');
|
|
assert.strictEqual(this.model.keyType, 'ec', 'sets the new selected value for key_type on the model.');
|
|
assert.strictEqual(
|
|
this.model.keyBits,
|
|
256,
|
|
'sets the new selected value for key_bits on the model based on the selection of key_type.'
|
|
);
|
|
|
|
await fillIn(SELECTORS.keyType, 'ed25519');
|
|
assert.strictEqual(
|
|
this.model.keyType,
|
|
'ed25519',
|
|
'sets the new selected value for key_type on the model.'
|
|
);
|
|
assert.strictEqual(
|
|
this.model.keyBits,
|
|
0,
|
|
'sets the new selected value for key_bits on the model based on the selection of key_type.'
|
|
);
|
|
|
|
await fillIn(SELECTORS.keyType, 'ec');
|
|
await fillIn(SELECTORS.keyBits, 384);
|
|
assert.strictEqual(this.model.keyType, 'ec', 'sets the new selected value for key_type on the model.');
|
|
assert.strictEqual(
|
|
this.model.keyBits,
|
|
384,
|
|
'sets the new selected value for key_bits on the model based on the selection of key_type.'
|
|
);
|
|
|
|
await fillIn(SELECTORS.signatureBits, '384');
|
|
assert.strictEqual(
|
|
this.model.signatureBits,
|
|
384,
|
|
'sets the new selected value for signature_bits on the model.'
|
|
);
|
|
|
|
await fillIn(SELECTORS.signatureBits, '0');
|
|
assert.strictEqual(
|
|
this.model.signatureBits,
|
|
0,
|
|
'sets the default value for signature_bits on the model.'
|
|
);
|
|
});
|
|
});
|