Vault SSH Cert Feature (#1596)
* feat: 🎸 Update models for vault ssh cert feature (#1591) ✅ Closes: ICU-7546 * feat: 🎸 Setup types in cred library forms and use HDS component (#1597) * feat: 🎸 Setup types in cred library forms and use HDS component ✅ Closes: ICU-7673 * feat: 🎸 Add vault ssh cert type for credential library (#1608) * feat: 🎸 Add vault ssh cert type for credential library ✅ Closes: ICU-7678 * feat: 🎸 Enable feature flag for vault ssh cert work (#1614) * fix: 🐛 Change fields to optional as they get default by backend (#1615) * Chore/cleanup vault ssh cert (#1616)
This commit is contained in:
1 parent
e3772352ea
commit
f0530e1f8f
34 files changed
+1421
-182
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from 'api/models/credential-library';
|
||||
|
||||
module('Unit | Model | credential library', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -13,7 +14,9 @@ module('Unit | Model | credential library', function (hooks) {
|
||||
test('it has isUnknown property and returns the expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelA = store.createRecord('credential-library', { type: 'vault' });
|
||||
const modelA = store.createRecord('credential-library', {
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
});
|
||||
const modelB = store.createRecord('credential-library', {
|
||||
type: 'unknown',
|
||||
});
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import {
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
} from 'api/models/credential-library';
|
||||
|
||||
module('Unit | Serializer | credential library', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -9,7 +13,7 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('credential-library');
|
||||
const record = store.createRecord('credential-library', {
|
||||
type: 'vault',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
path: '/vault/path',
|
||||
@@ -19,7 +23,7 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'vault',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
credential_store_id: null,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
@@ -27,6 +31,13 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
attributes: {
|
||||
path: '/vault/path',
|
||||
http_method: 'GET',
|
||||
critical_options: null,
|
||||
extensions: null,
|
||||
key_bits: null,
|
||||
key_id: null,
|
||||
key_type: null,
|
||||
ttl: null,
|
||||
username: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -40,7 +51,7 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
id: '1',
|
||||
type: 'credential-library',
|
||||
attributes: {
|
||||
type: 'vault',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
path: '/vault/path',
|
||||
@@ -53,13 +64,20 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'vault',
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
credential_store_id: null,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
attributes: {
|
||||
path: '/vault/path',
|
||||
http_method: 'GET',
|
||||
critical_options: null,
|
||||
extensions: null,
|
||||
key_bits: null,
|
||||
key_id: null,
|
||||
key_type: null,
|
||||
ttl: null,
|
||||
username: null,
|
||||
},
|
||||
version: 1,
|
||||
});
|
||||
@@ -75,8 +93,14 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
let serializedRecord = record.serialize();
|
||||
assert.deepEqual(serializedRecord, {
|
||||
attributes: {
|
||||
http_method: null,
|
||||
path: null,
|
||||
critical_options: null,
|
||||
extensions: null,
|
||||
key_bits: null,
|
||||
key_id: null,
|
||||
key_type: null,
|
||||
ttl: null,
|
||||
username: null,
|
||||
},
|
||||
credential_store_id: null,
|
||||
description: null,
|
||||
@@ -89,6 +113,7 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('credential-library', {
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
http_method: 'GET',
|
||||
http_request_body: 'body',
|
||||
});
|
||||
@@ -99,11 +124,18 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
attributes: {
|
||||
http_method: 'GET',
|
||||
path: null,
|
||||
critical_options: null,
|
||||
extensions: null,
|
||||
key_bits: null,
|
||||
key_id: null,
|
||||
key_type: null,
|
||||
ttl: null,
|
||||
username: null,
|
||||
},
|
||||
credential_store_id: null,
|
||||
description: null,
|
||||
name: null,
|
||||
type: null,
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
},
|
||||
'http_request_body attribute is not expected'
|
||||
);
|
||||
@@ -117,13 +149,66 @@ module('Unit | Serializer | credential library', function (hooks) {
|
||||
http_method: 'POST',
|
||||
http_request_body: 'body',
|
||||
path: null,
|
||||
critical_options: null,
|
||||
extensions: null,
|
||||
key_bits: null,
|
||||
key_id: null,
|
||||
key_type: null,
|
||||
ttl: null,
|
||||
username: null,
|
||||
},
|
||||
credential_store_id: null,
|
||||
description: null,
|
||||
name: null,
|
||||
type: null,
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
},
|
||||
'http_request_body attribute is expected'
|
||||
);
|
||||
});
|
||||
|
||||
test('it serializes vault_ssh_certificate correctly', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('credential-library');
|
||||
store.push({
|
||||
data: {
|
||||
id: '1',
|
||||
type: 'credential-library',
|
||||
attributes: {
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
version: 1,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
path: '/vault/path',
|
||||
username: 'user',
|
||||
key_type: 'rsa',
|
||||
key_bits: 100,
|
||||
ttl: '100',
|
||||
key_id: 'id',
|
||||
extensions: [{ key: 'key', value: 'value' }],
|
||||
critical_options: [{ key: 'key', value: 'value' }],
|
||||
},
|
||||
},
|
||||
});
|
||||
const record = store.peekRecord('credential-library', '1');
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
credential_store_id: null,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
attributes: {
|
||||
path: '/vault/path',
|
||||
username: 'user',
|
||||
key_type: 'rsa',
|
||||
key_bits: 100,
|
||||
ttl: '100',
|
||||
key_id: 'id',
|
||||
extensions: { key: 'value' },
|
||||
critical_options: { key: 'value' },
|
||||
},
|
||||
version: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Transform | object as array', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it deserializes an object to an array of key value objects', function (assert) {
|
||||
assert.expect(1);
|
||||
let transform = this.owner.lookup('transform:object-as-array');
|
||||
const deserialized = transform.deserialize({
|
||||
first: 'Hey',
|
||||
second: 'There',
|
||||
third: 'Everyone',
|
||||
});
|
||||
assert.deepEqual(deserialized, [
|
||||
{ key: 'first', value: 'Hey' },
|
||||
{ key: 'second', value: 'There' },
|
||||
{ key: 'third', value: 'Everyone' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('it deserializes undefined to an empty object', function (assert) {
|
||||
assert.expect(1);
|
||||
let transform = this.owner.lookup('transform:object-as-array');
|
||||
const deserialized = transform.deserialize(undefined);
|
||||
assert.deepEqual(deserialized, []);
|
||||
});
|
||||
|
||||
test('it serializes an array of key value objects to an object', function (assert) {
|
||||
assert.expect(1);
|
||||
let transform = this.owner.lookup('transform:object-as-array');
|
||||
const serialized = transform.serialize([
|
||||
{ key: 'first', value: 'Hey' },
|
||||
{ key: 'second', value: 'There' },
|
||||
{ key: 'third', value: 'Everyone' },
|
||||
]);
|
||||
|
||||
assert.deepEqual(serialized, {
|
||||
first: 'Hey',
|
||||
second: 'There',
|
||||
third: 'Everyone',
|
||||
});
|
||||
});
|
||||
|
||||
test('it serializes an empty array of key value objects to null', function (assert) {
|
||||
assert.expect(1);
|
||||
let transform = this.owner.lookup('transform:object-as-array');
|
||||
const serialized = transform.serialize([]);
|
||||
|
||||
assert.deepEqual(serialized, null);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user