Merge Boundary UI OSS branch 'main' at commit 63f619b1

This commit is contained in:
github-team-secure-boundary committed 2023-01-10 21:28:57 +00:00
commit 868adf096a
4 files changed
+156 -15

No files matched your search

@@ -39,6 +39,18 @@ export default class GeneratedTargetModel extends BaseModel {
})
worker_filter;
@attr('string', {
description:
'Optional boolean expressions to filter the egress workers that are allowed to satisfy this request.',
})
egress_worker_filter;
@attr('string', {
description:
'Optional boolean expressions to filter the ingress workers that are allowed to satisfy this request.',
})
ingress_worker_filter;
@attr('date', {
description: 'The time this resource was created\nOutput only.',
readOnly: true,
+2 -11
View File
@@ -22,7 +22,6 @@ export default factory.extend({
'add-credential-sources',
'remove-credential-sources',
],
id: () => generateId('t_'),
/**
@@ -31,17 +30,9 @@ export default factory.extend({
session_connection_limit: () =>
faker.helpers.arrayElement([-1, faker.datatype.number()]),
worker_filter: (i) => (i % 2 === 0 ? faker.random.words() : null),
egress_worker_filter: (i) => (i % 2 !== 0 ? faker.random.words() : null),
ingress_worker_filter: (i) => (i % 2 !== 0 ? faker.random.words() : null),
type: (i) => types[i % types.length],
/**
* Generates attributes fields by type.
*/
afterCreate(target) {
target.update({
attributes: {
default_port: faker.datatype.number(),
},
});
},
/**
* Randomly selects existing host sets and credential libraries to assign to target.
@@ -1,19 +1,16 @@
import { Factory } from 'miragejs';
import { faker } from '@faker-js/faker';
import { TYPE_TARGET_TCP } from 'api/models/target';
/**
* GeneratedTargetModelFactory
*/
export default Factory.extend({
type: TYPE_TARGET_TCP,
name: () => faker.random.words(),
session_max_seconds: () => faker.datatype.number(),
session_connection_limit: () => faker.datatype.number(),
worker_filter: () => faker.random.words(),
description: () => faker.random.words(),
created_time: () => faker.date.recent(),
updated_time: () => faker.date.recent(),
disabled: () => faker.datatype.boolean(),
default_port: () => faker.datatype.number(),
version: () => faker.datatype.number(),
});
@@ -42,6 +42,8 @@ module('Unit | Serializer | target', function (hooks) {
session_max_seconds: 28800,
session_connection_limit: null,
worker_filter: null,
egress_worker_filter: null,
ingress_worker_filter: null,
attributes: {
default_port: 1234,
},
@@ -119,6 +121,7 @@ module('Unit | Serializer | target', function (hooks) {
version: 1,
});
});
test('it serializes the worker_filter attribute if present', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
@@ -145,6 +148,78 @@ module('Unit | Serializer | target', function (hooks) {
session_max_seconds: 28800,
session_connection_limit: null,
worker_filter: 'worker',
egress_worker_filter: null,
ingress_worker_filter: null,
attributes: {
default_port: 1234,
},
address: null,
});
});
test('it serializes the egress_worker_filter attribute if present', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('target');
const record = store.createRecord('target', {
name: 'User',
description: 'Description',
version: 1,
type: TYPE_TARGET_SSH,
egress_worker_filter: 'egress worker',
default_port: 1234,
scope: {
scope_id: 'org_1',
},
});
const snapshot = record._createSnapshot();
const serializedRecord = serializer.serialize(snapshot);
assert.deepEqual(serializedRecord, {
name: 'User',
description: 'Description',
version: 1,
type: TYPE_TARGET_SSH,
scope_id: 'org_1',
session_max_seconds: 28800,
session_connection_limit: null,
worker_filter: null,
egress_worker_filter: 'egress worker',
ingress_worker_filter: null,
attributes: {
default_port: 1234,
},
address: null,
});
});
test('it serializes the ingress_worker_filter attribute if present', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('target');
const record = store.createRecord('target', {
name: 'User',
description: 'Description',
version: 1,
type: TYPE_TARGET_SSH,
ingress_worker_filter: 'ingress worker',
default_port: 1234,
scope: {
scope_id: 'org_1',
},
});
const snapshot = record._createSnapshot();
const serializedRecord = serializer.serialize(snapshot);
assert.deepEqual(serializedRecord, {
name: 'User',
description: 'Description',
version: 1,
type: TYPE_TARGET_SSH,
scope_id: 'org_1',
session_max_seconds: 28800,
session_connection_limit: null,
worker_filter: null,
egress_worker_filter: null,
ingress_worker_filter: 'ingress worker',
attributes: {
default_port: 1234,
},
@@ -292,4 +367,70 @@ module('Unit | Serializer | target', function (hooks) {
},
});
});
test('it normalizes the egress_worker_filter attribute if present', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('target');
const target = store.createRecord('target').constructor;
const payload = {
id: '1',
name: 'Target 1',
egress_worker_filter: 'egress worker',
};
const normalized = serializer.normalizeSingleResponse(
store,
target,
payload
);
assert.deepEqual(normalized, {
included: [],
data: {
id: '1',
type: 'target',
attributes: {
authorized_actions: [],
name: 'Target 1',
host_sources: [],
brokered_credential_source_ids: [],
injected_application_credential_source_ids: [],
egress_worker_filter: 'egress worker',
},
relationships: {},
},
});
});
test('it normalizes the ingress_worker_filter attribute if present', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('target');
const target = store.createRecord('target').constructor;
const payload = {
id: '1',
name: 'Target 1',
ingress_worker_filter: 'ingress worker',
};
const normalized = serializer.normalizeSingleResponse(
store,
target,
payload
);
assert.deepEqual(normalized, {
included: [],
data: {
id: '1',
type: 'target',
attributes: {
authorized_actions: [],
name: 'Target 1',
host_sources: [],
brokered_credential_source_ids: [],
injected_application_credential_source_ids: [],
ingress_worker_filter: 'ingress worker',
},
relationships: {},
},
});
});
});