Refactor edition enablement (#1657)
* refactor: 💡 consolidate ssh features into ssh-target flag ✅ Closes: ICU-8383 * refactor: 💡 factor out base edition * feat: 🎸 dynamic feature edition enablement and toggling
This commit is contained in:
1 parent
bd6eee8eb3
commit
acd719140d
24 files changed
+303
-91
No files matched your search
@@ -225,7 +225,7 @@ module('Acceptance | credential-libraries | create', function (hooks) {
|
||||
|
||||
test('cannot select vault ssh cert when feature is disabled', async function (assert) {
|
||||
const featuresService = this.owner.lookup('service:features');
|
||||
featuresService.disable('credential-library-vault-ssh-certificate');
|
||||
featuresService.disable('ssh-target');
|
||||
assert.expect(1);
|
||||
await visit(urls.newCredentialLibrary);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ module('Acceptance | credential-libraries | read', function (hooks) {
|
||||
`${urls.credentialLibraries}/${instances.credentialLibrary.id}`
|
||||
);
|
||||
const featuresService = this.owner.lookup('service:features');
|
||||
featuresService.disable('credential-library-vault-ssh-certificate');
|
||||
featuresService.disable('ssh-target');
|
||||
await visit(urls.credentialLibraries);
|
||||
|
||||
assert.dom('.rose-table-body tr:nth-of-type(2) a').doesNotExist();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, getContext } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
|
||||
module('Acceptance | develop', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let featuresService;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const { owner } = getContext();
|
||||
featuresService = owner.lookup('service:features');
|
||||
});
|
||||
|
||||
test('edition toggle is hidden when `dev-edition-toggle` is false', async function (assert) {
|
||||
await visit('/');
|
||||
assert.false(featuresService.isEnabled('dev-edition-toggle'));
|
||||
assert.dom('data-dev-edition-toggle').doesNotExist();
|
||||
});
|
||||
|
||||
test('edition toggle is visible when `dev-edition-toggle` is true', async function (assert) {
|
||||
assert.false(featuresService.isEnabled('dev-edition-toggle'));
|
||||
featuresService.enable('dev-edition-toggle');
|
||||
await visit('/');
|
||||
assert.dom('data-dev-edition-toggle').doesNotExist();
|
||||
});
|
||||
});
|
||||
@@ -125,7 +125,10 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await click('[value="ssh"]');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
await fillIn('[name="egress_worker_filter"]', 'random filter');
|
||||
await click('[type="submit"]');
|
||||
|
||||
@@ -178,7 +181,10 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await click('[value="tcp"]');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
await fillIn('[name="egress_worker_filter"]', 'random filter');
|
||||
|
||||
await click('[type="submit"]');
|
||||
@@ -301,7 +307,10 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
await fillIn('[name="egress_worker_filter"]', 'random filter');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
|
||||
@@ -318,7 +327,10 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[value="ssh"]');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
await fillIn('[name="egress_worker_filter"]', 'random filter');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
|
||||
|
||||
@@ -164,16 +164,21 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
|
||||
test('hide filter input field when the `egress_worker_filter` toggled is off', async function (assert) {
|
||||
featuresService.enable('target-worker-filters-v2');
|
||||
featuresService.enable('target-worker-filters-v2-ingress');
|
||||
assert.expect(1);
|
||||
await visit(urls.target);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await click('.hds-button[type="button"]', 'Update Filter');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
assert.dom('[name=egress_worker_filter]').isNotVisible();
|
||||
});
|
||||
|
||||
test('clear `egress_worker_field` value from a target when the toggle is off and form is saved', async function (assert) {
|
||||
featuresService.enable('target-worker-filters-v2');
|
||||
featuresService.enable('target-worker-filters-v2-ingress');
|
||||
assert.expect(5);
|
||||
await visit(urls.target);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
@@ -186,7 +191,10 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
'random filter string'
|
||||
);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await click('.hds-form-toggle__control', 'Egress worker filter');
|
||||
await click(
|
||||
'[name="target-worker-filter-toggle-egress_worker_filter"]',
|
||||
'Egress toggle'
|
||||
);
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
//clear egress_worker_filter when the toggle is off
|
||||
assert.strictEqual(currentURL(), urls.target);
|
||||
|
||||
@@ -137,9 +137,9 @@ test('Static Credential Store (User & Key Pair)', async ({ page }) => {
|
||||
if (process.env.E2E_SSH_USER != retrievedUser) {
|
||||
throw new Error(
|
||||
'Stored User does not match. EXPECTED: ' +
|
||||
process.env.E2E_SSH_USER +
|
||||
', ACTUAL: ' +
|
||||
retrievedUser
|
||||
process.env.E2E_SSH_USER +
|
||||
', ACTUAL: ' +
|
||||
retrievedUser
|
||||
);
|
||||
}
|
||||
if (keyData != retrievedKey) {
|
||||
|
||||
@@ -59,8 +59,8 @@ test('Vault Credential Store (User & Key Pair)', async ({ page }) => {
|
||||
execSync(`vault secrets enable -path=${secretsPath} kv-v2`);
|
||||
execSync(
|
||||
`vault kv put -mount ${secretsPath} ${secretName} ` +
|
||||
` username=${process.env.E2E_SSH_USER}` +
|
||||
` private_key=@${process.env.E2E_SSH_KEY_PATH}`
|
||||
` username=${process.env.E2E_SSH_USER}` +
|
||||
` private_key=@${process.env.E2E_SSH_KEY_PATH}`
|
||||
);
|
||||
execSync(
|
||||
`vault policy write ${secretPolicyName} ./tests/e2e/tests/fixtures/kv-policy.hcl`
|
||||
@@ -68,13 +68,13 @@ test('Vault Credential Store (User & Key Pair)', async ({ page }) => {
|
||||
const vaultToken = JSON.parse(
|
||||
execSync(
|
||||
`vault token create` +
|
||||
` -no-default-policy=true` +
|
||||
` -policy=${boundaryPolicyName}` +
|
||||
` -policy=${secretPolicyName}` +
|
||||
` -orphan=true` +
|
||||
` -period=20m` +
|
||||
` -renewable=true` +
|
||||
` -format=json`
|
||||
` -no-default-policy=true` +
|
||||
` -policy=${boundaryPolicyName}` +
|
||||
` -policy=${secretPolicyName}` +
|
||||
` -orphan=true` +
|
||||
` -period=20m` +
|
||||
` -renewable=true` +
|
||||
` -format=json`
|
||||
)
|
||||
);
|
||||
const clientToken = vaultToken.auth.client_token;
|
||||
@@ -175,9 +175,9 @@ test('Vault Credential Store (User & Key Pair)', async ({ page }) => {
|
||||
if (process.env.E2E_SSH_USER != retrievedUser) {
|
||||
throw new Error(
|
||||
'Stored User does not match. EXPECTED: ' +
|
||||
process.env.E2E_SSH_USER +
|
||||
', ACTUAL: ' +
|
||||
retrievedUser
|
||||
process.env.E2E_SSH_USER +
|
||||
', ACTUAL: ' +
|
||||
retrievedUser
|
||||
);
|
||||
}
|
||||
if (keyData != retrievedKey) {
|
||||
|
||||
@@ -128,9 +128,9 @@ test.describe('AWS', async () => {
|
||||
if (!hostsAreVisible) {
|
||||
throw new Error(
|
||||
'Hosts are not visible. EXPECTED: ' +
|
||||
expectedHosts.length +
|
||||
', ACTUAL: ' +
|
||||
rowCount
|
||||
expectedHosts.length +
|
||||
', ACTUAL: ' +
|
||||
rowCount
|
||||
);
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ test.describe('AWS', async () => {
|
||||
if (!hostsAreVisible) {
|
||||
throw new Error(
|
||||
'Hosts are not visible. EXPECTED: ' +
|
||||
expectedHosts.length +
|
||||
', ACTUAL: ' +
|
||||
rowCount
|
||||
expectedHosts.length +
|
||||
', ACTUAL: ' +
|
||||
rowCount
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -61,18 +61,18 @@ test('Verify session created then cancel the session', async ({ page }) => {
|
||||
|
||||
connect = exec(
|
||||
'boundary connect' +
|
||||
' -target-id=' +
|
||||
target.id +
|
||||
' -exec /usr/bin/ssh --' +
|
||||
' -l ' +
|
||||
process.env.E2E_SSH_USER +
|
||||
' -i ' +
|
||||
process.env.E2E_SSH_KEY_PATH +
|
||||
' -o UserKnownHostsFile=/dev/null' +
|
||||
' -o StrictHostKeyChecking=no' +
|
||||
' -o IdentitiesOnly=yes' + // forces the use of the provided key
|
||||
' -p {{boundary.port}}' +
|
||||
' {{boundary.ip}}'
|
||||
' -target-id=' +
|
||||
target.id +
|
||||
' -exec /usr/bin/ssh --' +
|
||||
' -l ' +
|
||||
process.env.E2E_SSH_USER +
|
||||
' -i ' +
|
||||
process.env.E2E_SSH_KEY_PATH +
|
||||
' -o UserKnownHostsFile=/dev/null' +
|
||||
' -o StrictHostKeyChecking=no' +
|
||||
' -o IdentitiesOnly=yes' + // forces the use of the provided key
|
||||
' -p {{boundary.port}}' +
|
||||
' {{boundary.ip}}'
|
||||
);
|
||||
|
||||
await page
|
||||
|
||||
@@ -17,7 +17,7 @@ module('Unit | Abilities | credential-library', function (hooks) {
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
features = this.owner.lookup('service:features');
|
||||
features.enable('credential-library-vault-ssh-certificate');
|
||||
features.enable('ssh-target');
|
||||
});
|
||||
|
||||
test('can read credential library type when authorized and feature is enabled', function (assert) {
|
||||
@@ -51,7 +51,7 @@ module('Unit | Abilities | credential-library', function (hooks) {
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
const featuresService = this.owner.lookup('service:features');
|
||||
featuresService.disable('credential-library-vault-ssh-certificate');
|
||||
featuresService.disable('ssh-target');
|
||||
const credentialLibrary = store.createRecord('credential-library', {
|
||||
authorized_actions: [],
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
@@ -66,7 +66,7 @@ module('Unit | Abilities | credential-library', function (hooks) {
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
const featuresService = this.owner.lookup('service:features');
|
||||
featuresService.disable('credential-library-vault-ssh-certificate');
|
||||
featuresService.disable('ssh-target');
|
||||
const credentialLibrary = store.createRecord('credential-library', {
|
||||
authorized_actions: ['read'],
|
||||
type: TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import Application from '@ember/application';
|
||||
|
||||
import config from 'admin/config/environment';
|
||||
import { initialize } from 'admin/instance-initializers/feature-edition';
|
||||
import { module, test } from 'qunit';
|
||||
import Resolver from 'ember-resolver';
|
||||
import { run } from '@ember/runloop';
|
||||
|
||||
module('Unit | Instance Initializer | feature-edition', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
this.TestApplication = class TestApplication extends Application {
|
||||
modulePrefix = config.modulePrefix;
|
||||
podModulePrefix = config.podModulePrefix;
|
||||
Resolver = Resolver;
|
||||
};
|
||||
|
||||
this.TestApplication.instanceInitializer({
|
||||
name: 'initializer under test',
|
||||
initialize,
|
||||
});
|
||||
|
||||
this.application = this.TestApplication.create({
|
||||
autoboot: false,
|
||||
});
|
||||
|
||||
this.instance = this.application.buildInstance();
|
||||
});
|
||||
hooks.afterEach(function () {
|
||||
run(this.instance, 'destroy');
|
||||
run(this.application, 'destroy');
|
||||
});
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it works', async function (assert) {
|
||||
await this.instance.boot();
|
||||
|
||||
assert.ok(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'admin/tests/helpers';
|
||||
|
||||
module('Unit | Service | features', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let service = this.owner.lookup('service:features');
|
||||
assert.ok(service);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user