2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
import { module, test } from 'qunit';
|
2024-11-19 15:18:18 -08:00
|
|
|
import { visit, fillIn, click, findAll, currentURL } from '@ember/test-helpers';
|
2024-12-02 12:51:24 -06:00
|
|
|
import { setupApplicationTest } from 'admin/tests/helpers';
|
2022-08-26 11:50:53 -04:00
|
|
|
import { Response } from 'miragejs';
|
2025-02-13 15:54:40 -05:00
|
|
|
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
2025-03-20 14:02:13 -07:00
|
|
|
import * as selectors from './selectors';
|
2025-08-11 11:04:07 -07:00
|
|
|
import { setRunOptions } from 'ember-a11y-testing/test-support';
|
2022-08-26 11:50:53 -04:00
|
|
|
|
|
|
|
|
module('Acceptance | workers | create', function (hooks) {
|
|
|
|
|
setupApplicationTest(hooks);
|
|
|
|
|
|
|
|
|
|
let globalScope;
|
|
|
|
|
let workersURL;
|
|
|
|
|
let newWorkerURL;
|
|
|
|
|
let getWorkersCount;
|
2025-03-20 14:02:13 -07:00
|
|
|
let featuresService;
|
2022-08-26 11:50:53 -04:00
|
|
|
|
2024-12-03 10:27:27 -08:00
|
|
|
hooks.beforeEach(async function () {
|
2025-10-30 12:49:30 -07:00
|
|
|
globalScope = this.server.schema.scopes.find('global');
|
2022-08-26 11:50:53 -04:00
|
|
|
|
|
|
|
|
workersURL = `/scopes/global/workers`;
|
|
|
|
|
newWorkerURL = `${workersURL}/new`;
|
|
|
|
|
getWorkersCount = () => this.server.schema.workers.all().length;
|
2025-03-20 14:02:13 -07:00
|
|
|
featuresService = this.owner.lookup('service:features');
|
2022-08-26 11:50:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can create new workers', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
const workersCount = getWorkersCount();
|
|
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
await fillIn(
|
|
|
|
|
selectors.FIELD_WORKER_AUTH_REGISTRATION,
|
|
|
|
|
selectors.FIELD_WORKER_AUTH_REGISTRATION_VALUE,
|
|
|
|
|
);
|
|
|
|
|
await click(commonSelectors.SAVE_BTN);
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
assert.strictEqual(getWorkersCount(), workersCount + 1);
|
|
|
|
|
});
|
|
|
|
|
|
2022-09-12 16:04:29 -04:00
|
|
|
test('cluster id input field is visible for `hcp` binary', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-02 14:30:10 -04:00
|
|
|
featuresService.enable('byow-pki-hcp-cluster-id');
|
2022-09-12 16:04:29 -04:00
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
const labels = findAll(selectors.WORKER_CREATE_SECTION_FORM_LABEL);
|
|
|
|
|
|
2024-02-28 13:02:02 -05:00
|
|
|
assert.dom(labels[0]).hasText('Boundary Cluster ID (Optional)');
|
2022-09-12 16:04:29 -04:00
|
|
|
assert.dom(labels[2]).doesNotIncludeText('Initial Upstreams');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('initial upstreams input field is visible for `oss` binary', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-09-12 16:04:29 -04:00
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
const labels = findAll(selectors.WORKER_CREATE_SECTION_FORM_LABEL);
|
|
|
|
|
|
2023-03-31 17:38:17 -07:00
|
|
|
assert.false(featuresService.isEnabled('byow-pki-hcp-cluster-id'));
|
2022-09-12 16:04:29 -04:00
|
|
|
assert.dom(labels[0]).doesNotIncludeText('Boundary Cluster ID');
|
2024-02-28 13:02:02 -05:00
|
|
|
assert.dom(labels[2]).hasText('Initial Upstreams (Optional)');
|
2022-09-12 16:04:29 -04:00
|
|
|
});
|
|
|
|
|
|
2022-12-12 18:55:28 -06:00
|
|
|
test('download and install step shows correct oss instructions', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-12-12 18:55:28 -06:00
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
const createSection = findAll(selectors.WORKER_CREATE_SECTION);
|
|
|
|
|
|
2023-03-31 17:38:17 -07:00
|
|
|
assert.false(featuresService.isEnabled('byow-pki-hcp-cluster-id'));
|
2023-05-04 15:14:00 -04:00
|
|
|
assert
|
|
|
|
|
.dom(createSection[1])
|
|
|
|
|
.includesText(
|
2023-11-22 14:07:41 -05:00
|
|
|
'curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - ;',
|
2023-05-04 15:14:00 -04:00
|
|
|
);
|
|
|
|
|
assert
|
|
|
|
|
.dom(createSection[1])
|
|
|
|
|
.doesNotIncludeText(
|
2023-11-22 14:07:41 -05:00
|
|
|
'wget -q "$(curl -fsSL "https://api.releases.hashicorp.com/v1/releases/boundary/latest?license_class=enterprise"',
|
2023-05-04 15:14:00 -04:00
|
|
|
);
|
2022-12-12 18:55:28 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('download and install step shows correct hcp instructions', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-12-12 18:55:28 -06:00
|
|
|
featuresService.enable('byow-pki-hcp-cluster-id');
|
|
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
const createSection = findAll(selectors.WORKER_CREATE_SECTION);
|
|
|
|
|
|
2023-05-04 15:14:00 -04:00
|
|
|
assert
|
|
|
|
|
.dom(createSection[1])
|
|
|
|
|
.includesText(
|
2023-11-22 14:07:41 -05:00
|
|
|
'wget -q "$(curl -fsSL "https://api.releases.hashicorp.com/v1/releases/boundary/latest?license_class=enterprise"',
|
2023-05-04 15:14:00 -04:00
|
|
|
);
|
|
|
|
|
assert
|
|
|
|
|
.dom(createSection[1])
|
|
|
|
|
.doesNotIncludeText(
|
2023-11-22 14:07:41 -05:00
|
|
|
'curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - ;',
|
2023-05-04 15:14:00 -04:00
|
|
|
);
|
2022-12-12 18:55:28 -06:00
|
|
|
});
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
test('Users can navigate to new workers route with proper authorization', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-17 09:45:34 -07:00
|
|
|
await visit(workersURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
assert.ok(
|
|
|
|
|
globalScope.authorized_collection_actions.workers.includes(
|
2023-11-22 14:07:41 -05:00
|
|
|
'create:worker-led',
|
|
|
|
|
),
|
2022-08-26 11:50:53 -04:00
|
|
|
);
|
2025-03-20 14:02:13 -07:00
|
|
|
assert.dom(commonSelectors.HREF(newWorkerURL)).isVisible();
|
2022-08-26 11:50:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Users cannot navigate to new workers route without proper authorization', async function (assert) {
|
|
|
|
|
globalScope.authorized_collection_actions.workers = [];
|
|
|
|
|
await visit(workersURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
assert.notOk(
|
|
|
|
|
globalScope.authorized_collection_actions.users.includes(
|
2023-11-22 14:07:41 -05:00
|
|
|
'create:worker-led',
|
|
|
|
|
),
|
2022-08-26 11:50:53 -04:00
|
|
|
);
|
2025-03-20 14:02:13 -07:00
|
|
|
assert.dom(commonSelectors.HREF(newWorkerURL)).isNotVisible();
|
2022-08-26 11:50:53 -04:00
|
|
|
});
|
|
|
|
|
|
2024-07-11 12:29:43 -05:00
|
|
|
test('saving a new worker with invalid fields displays error messages', async function (assert) {
|
2025-08-11 11:04:07 -07:00
|
|
|
setRunOptions({
|
|
|
|
|
rules: {
|
|
|
|
|
'color-contrast': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'heading-order': {
|
|
|
|
|
// [ember-a11y-ignore]: axe rule "heading-order" automatically ignored on 2025-08-01
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-26 11:50:53 -04:00
|
|
|
this.server.post('/workers:create:worker-led', () => {
|
|
|
|
|
return new Response(
|
|
|
|
|
500,
|
|
|
|
|
{},
|
|
|
|
|
{
|
|
|
|
|
status: 500,
|
|
|
|
|
code: 'api_error',
|
|
|
|
|
message: 'rpc error: code = Unknown',
|
2023-11-22 14:07:41 -05:00
|
|
|
},
|
2022-08-26 11:50:53 -04:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await visit(newWorkerURL);
|
2025-03-20 14:02:13 -07:00
|
|
|
|
|
|
|
|
await fillIn(
|
|
|
|
|
selectors.FIELD_WORKER_AUTH_REGISTRATION,
|
|
|
|
|
selectors.FIELD_WORKER_AUTH_REGISTRATION_VALUE,
|
|
|
|
|
);
|
|
|
|
|
await click(commonSelectors.SAVE_BTN);
|
|
|
|
|
|
2024-11-19 15:18:18 -08:00
|
|
|
assert
|
2025-02-13 15:54:40 -05:00
|
|
|
.dom(commonSelectors.ALERT_TOAST_BODY)
|
2024-11-19 15:18:18 -08:00
|
|
|
.hasText('rpc error: code = Unknown');
|
2022-08-26 11:50:53 -04:00
|
|
|
});
|
2023-11-02 16:08:25 -07:00
|
|
|
|
|
|
|
|
test('users cannot directly navigate to new worker route without proper authorization', async function (assert) {
|
|
|
|
|
globalScope.authorized_collection_actions.workers =
|
|
|
|
|
globalScope.authorized_collection_actions.workers.filter(
|
2023-11-22 14:07:41 -05:00
|
|
|
(item) => item !== 'create:worker-led',
|
2023-11-02 16:08:25 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await visit(newWorkerURL);
|
|
|
|
|
|
|
|
|
|
assert.false(
|
|
|
|
|
globalScope.authorized_collection_actions.workers.includes(
|
2023-11-22 14:07:41 -05:00
|
|
|
'create:worker-led',
|
|
|
|
|
),
|
2023-11-02 16:08:25 -07:00
|
|
|
);
|
|
|
|
|
assert.strictEqual(currentURL(), workersURL);
|
|
|
|
|
});
|
2022-08-26 11:50:53 -04:00
|
|
|
});
|