2023-06-19 16:23:53 +00:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-06-19 16:23:53 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-03-21 17:35:43 -07:00
|
|
|
import { module, test } from 'qunit';
|
2023-03-27 11:43:05 -05:00
|
|
|
import { visit, currentURL, click } from '@ember/test-helpers';
|
2023-03-21 17:35:43 -07:00
|
|
|
import { setupApplicationTest } from 'admin/tests/helpers';
|
2025-06-05 11:00:25 -07:00
|
|
|
import { setupIntl } from 'ember-intl/test-support';
|
2025-08-26 11:31:30 -07:00
|
|
|
import { setupSqlite } from 'api/test-support/helpers/sqlite';
|
2025-05-05 10:41:42 -07:00
|
|
|
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
|
|
|
|
import * as selectors from './selectors';
|
2025-08-11 11:04:07 -07:00
|
|
|
import { setRunOptions } from 'ember-a11y-testing/test-support';
|
2023-03-21 17:35:43 -07:00
|
|
|
|
2023-11-02 16:08:25 -07:00
|
|
|
module('Acceptance | session-recordings | read', function (hooks) {
|
2023-03-21 17:35:43 -07:00
|
|
|
setupApplicationTest(hooks);
|
2025-08-26 11:31:30 -07:00
|
|
|
setupSqlite(hooks);
|
2025-06-05 11:00:25 -07:00
|
|
|
setupIntl(hooks, 'en-us');
|
2023-03-21 17:35:43 -07:00
|
|
|
|
2023-04-03 20:28:31 -07:00
|
|
|
let featuresService;
|
|
|
|
|
|
2023-03-21 17:35:43 -07:00
|
|
|
// Instances
|
|
|
|
|
const instances = {
|
|
|
|
|
scopes: {
|
|
|
|
|
global: null,
|
|
|
|
|
org: null,
|
|
|
|
|
},
|
2024-10-01 13:55:15 -05:00
|
|
|
target: null,
|
|
|
|
|
user: null,
|
2023-03-21 17:35:43 -07:00
|
|
|
sessionRecording: null,
|
|
|
|
|
};
|
|
|
|
|
// Urls
|
|
|
|
|
const urls = {
|
|
|
|
|
globalScope: null,
|
|
|
|
|
sessionRecordings: null,
|
|
|
|
|
sessionRecording: null,
|
2023-03-27 11:43:05 -05:00
|
|
|
channelRecording: null,
|
2023-03-21 17:35:43 -07:00
|
|
|
};
|
|
|
|
|
|
2024-12-03 10:27:27 -08:00
|
|
|
hooks.beforeEach(async function () {
|
2025-10-30 12:49:30 -07:00
|
|
|
instances.scopes.global = this.server.schema.scopes.find('global');
|
2023-03-21 17:35:43 -07:00
|
|
|
instances.scopes.org = this.server.create('scope', {
|
|
|
|
|
type: 'org',
|
|
|
|
|
scope: { id: 'global', type: 'global' },
|
|
|
|
|
});
|
2023-05-05 13:49:57 -05:00
|
|
|
instances.target = this.server.create('target', {
|
|
|
|
|
scope: instances.scopes.global,
|
|
|
|
|
});
|
2024-10-01 13:55:15 -05:00
|
|
|
instances.user = this.server.create('user');
|
2023-03-21 17:35:43 -07:00
|
|
|
instances.sessionRecording = this.server.create('session-recording', {
|
|
|
|
|
scope: instances.scopes.global,
|
2023-05-08 14:05:01 -04:00
|
|
|
create_time_values: {
|
|
|
|
|
target: instances.target.attrs,
|
2024-10-01 13:55:15 -05:00
|
|
|
user: instances.user.attrs,
|
2023-05-08 14:05:01 -04:00
|
|
|
},
|
2023-03-21 17:35:43 -07:00
|
|
|
});
|
2023-03-27 11:43:05 -05:00
|
|
|
instances.connectionRecording = this.server.create('connection-recording', {
|
|
|
|
|
session_recording: instances.sessionRecording,
|
|
|
|
|
});
|
|
|
|
|
instances.channelRecording = this.server.create('channel-recording', {
|
|
|
|
|
connection_recording: instances.connectionRecording,
|
|
|
|
|
});
|
2023-03-21 17:35:43 -07:00
|
|
|
urls.globalScope = `/scopes/global`;
|
|
|
|
|
urls.sessionRecordings = `${urls.globalScope}/session-recordings`;
|
2023-04-27 09:35:52 -07:00
|
|
|
urls.sessionRecording = `${urls.sessionRecordings}/${instances.sessionRecording.id}/channels-by-connection`;
|
|
|
|
|
urls.channelRecording = `${urls.sessionRecording}/${instances.channelRecording.id}`;
|
2023-04-03 20:28:31 -07:00
|
|
|
featuresService = this.owner.lookup('service:features');
|
2023-03-21 17:35:43 -07:00
|
|
|
});
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
test('visiting a session recording', 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-05-22 08:49:30 -07:00
|
|
|
featuresService.enable('ssh-session-recording');
|
2025-05-05 10:41:42 -07:00
|
|
|
await visit(urls.globalScope);
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
// Visit session recordings
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(commonSelectors.HREF(urls.sessionRecordings));
|
2023-03-30 11:11:40 -05:00
|
|
|
// Click a session recording and check it navigates properly
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(selectors.TABLE_FIRST_ROW_ACTION_LINK);
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
assert.strictEqual(currentURL(), urls.sessionRecording);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('user can navigate to a session recording 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-05-22 08:49:30 -07:00
|
|
|
featuresService.enable('ssh-session-recording');
|
2025-05-05 10:41:42 -07:00
|
|
|
await visit(urls.globalScope);
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
// Visit session recordings
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(commonSelectors.HREF(urls.sessionRecordings));
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
assert.true(instances.sessionRecording.authorized_actions.includes('read'));
|
2025-05-05 10:41:42 -07:00
|
|
|
assert.dom(commonSelectors.HREF(urls.sessionRecording)).isVisible();
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
// Click a session recording and check it navigates properly
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(selectors.TABLE_FIRST_ROW_ACTION_LINK);
|
|
|
|
|
|
2023-03-21 17:35:43 -07:00
|
|
|
assert.strictEqual(currentURL(), urls.sessionRecording);
|
|
|
|
|
});
|
2023-03-27 11:43:05 -05:00
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
test('user cannot navigate to a session recording without the read action', 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-05-22 08:49:30 -07:00
|
|
|
featuresService.enable('ssh-session-recording');
|
2023-03-30 11:11:40 -05:00
|
|
|
instances.sessionRecording.authorized_actions =
|
|
|
|
|
instances.sessionRecording.authorized_actions.filter(
|
2023-11-22 14:07:41 -05:00
|
|
|
(item) => item !== 'read',
|
2023-03-30 11:11:40 -05:00
|
|
|
);
|
2025-05-05 10:41:42 -07:00
|
|
|
await visit(urls.globalScope);
|
|
|
|
|
|
2023-03-30 11:11:40 -05:00
|
|
|
// Visit session recordings
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(commonSelectors.HREF(urls.sessionRecordings));
|
|
|
|
|
|
|
|
|
|
assert.dom(selectors.TABLE_FIRST_ROW_ACTION_LINK).doesNotExist();
|
2023-03-30 11:11:40 -05:00
|
|
|
});
|
|
|
|
|
|
2023-03-27 11:43:05 -05:00
|
|
|
test('user can navigate to a channel recording', 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-05-22 08:49:30 -07:00
|
|
|
featuresService.enable('ssh-session-recording');
|
2025-05-05 10:41:42 -07:00
|
|
|
await visit(urls.sessionRecordings);
|
|
|
|
|
|
|
|
|
|
// Visit session recordings
|
|
|
|
|
await click(commonSelectors.HREF(urls.sessionRecording));
|
2023-03-27 11:43:05 -05:00
|
|
|
// Click a channel recording and check it navigates properly
|
2025-05-05 10:41:42 -07:00
|
|
|
await click(selectors.TABLE_FIRST_ROW_ACTION_LINK);
|
|
|
|
|
|
2023-03-27 11:43:05 -05:00
|
|
|
assert.strictEqual(currentURL(), urls.channelRecording);
|
|
|
|
|
});
|
2023-11-02 16:08:25 -07:00
|
|
|
|
2025-05-05 10:41:42 -07:00
|
|
|
test('users can navigate to session recording and incorrect url auto-corrects', 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-11-02 16:08:25 -07:00
|
|
|
featuresService.enable('ssh-session-recording');
|
|
|
|
|
const incorrectUrl = `/scopes/${instances.scopes.org.id}/session-recordings/${instances.sessionRecording.id}/channels-by-connection`;
|
|
|
|
|
|
|
|
|
|
await visit(incorrectUrl);
|
|
|
|
|
|
|
|
|
|
assert.notEqual(currentURL(), incorrectUrl);
|
|
|
|
|
assert.strictEqual(currentURL(), urls.sessionRecording);
|
|
|
|
|
});
|
2023-03-21 17:35:43 -07:00
|
|
|
});
|