Merge remote-tracking branch 'origin/session-recording' into ICU-8380-style-ember-asciinema-player-for-session-recording-player-component
This commit is contained in:
commit
1d6b9275f0
21 files changed
+713
-20
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import ModelAbility from './model';
|
||||
|
||||
/**
|
||||
* Provides abilities for storage buckets.
|
||||
*/
|
||||
export default class StorageBucketAbility extends ModelAbility {
|
||||
// =services
|
||||
|
||||
// =permissions
|
||||
|
||||
/**
|
||||
* Only "known" storage bucket types may be read.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canRead() {
|
||||
return !this.model.isUnknown && this.hasAuthorizedAction('read');
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage buckets can only exist within global and org scopes.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canCreate() {
|
||||
return (
|
||||
this.hasAuthorizedCollectionAction('create') &&
|
||||
(this.model.isGlobal || this.model.isOrg)
|
||||
);
|
||||
}
|
||||
|
||||
get canList() {
|
||||
return (
|
||||
this.hasAuthorizedCollectionAction('list') &&
|
||||
(this.model.isGlobal || this.model.isOrg)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
export { default } from 'api/abilities/storage-bucket';
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import StorageBucketAbility from 'api/abilities/storage-bucket';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class OverrideStorageBucketAbility extends StorageBucketAbility {
|
||||
// =service
|
||||
@service features;
|
||||
|
||||
/**
|
||||
* This override ensures that storage buckets may be read only if the
|
||||
* session-recording feature flag is enabled.
|
||||
*/
|
||||
get canRead() {
|
||||
return this.features.isEnabled('session-recording') ? super.canRead : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This override ensures that storage buckets can only be presented in the global scope.
|
||||
*/
|
||||
get canList() {
|
||||
return this.hasAuthorizedCollectionAction('list') && this.model.isGlobal;
|
||||
}
|
||||
|
||||
get canNavigate() {
|
||||
return this.canCreate || this.canList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class='layout-sidebar-body'>
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div ...attributes class='layout-sidebar'>
|
||||
{{yield
|
||||
(hash
|
||||
Body=(component 'layout/sidebar/body')
|
||||
Sidebar=(component 'layout/sidebar/sidebar')
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class='layout-sidebar-sidebar'>
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeStorageBucketsController extends Controller {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
|
||||
// = attributes
|
||||
/**
|
||||
* Translated breadcrumb
|
||||
* @type {string}
|
||||
*/
|
||||
get breadCrumb() {
|
||||
return this.intl.t('resources.storage-bucket.title_plural');
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,9 @@
|
||||
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeStorageBucketsRoute extends Route {}
|
||||
export default class ScopesScopeStorageBucketsRoute extends Route {
|
||||
model() {
|
||||
// Temporary placeholder
|
||||
return [{ scope_id: 'sb_123456' }];
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,12 @@
|
||||
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeStorageBucketsIndexRoute extends Route {}
|
||||
export default class ScopesScopeStorageBucketsIndexRoute extends Route {
|
||||
// =methods
|
||||
|
||||
setupController(controller) {
|
||||
const scope = this.modelFor('scopes.scope');
|
||||
super.setupController(...arguments);
|
||||
controller.setProperties({ scope });
|
||||
}
|
||||
}
|
||||
@@ -750,3 +750,28 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// Layout - Sidebar
|
||||
.layout-sidebar {
|
||||
display: grid;
|
||||
grid-template-areas: 'body body sidebar';
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-rows: auto 1fr;
|
||||
gap: 2rem;
|
||||
|
||||
.layout-sidebar-body {
|
||||
grid-area: body;
|
||||
}
|
||||
|
||||
.layout-sidebar-sidebar {
|
||||
grid-area: sidebar;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: media.width(large)) {
|
||||
.layout-sidebar {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-areas:
|
||||
'body'
|
||||
'sidebar';
|
||||
}
|
||||
}
|
||||
@@ -32,13 +32,15 @@
|
||||
<Rose::Icon @name='flight-icons/svg/film-16' @size='medium' />
|
||||
{{t 'resources.session-recording.title_plural'}}
|
||||
</nav.link>
|
||||
<nav.link @route='scopes.scope.storage-buckets'>
|
||||
<Rose::Icon
|
||||
@name='flight-icons/svg/cloud-upload-16'
|
||||
@size='medium'
|
||||
/>
|
||||
{{t 'resources.storage-bucket.title_plural'}}
|
||||
</nav.link>
|
||||
{{#if (can 'navigate model' @model collection='storage-buckets')}}
|
||||
<nav.link @route='scopes.scope.storage-buckets'>
|
||||
<Rose::Icon
|
||||
@name='flight-icons/svg/cloud-upload-16'
|
||||
@size='medium'
|
||||
/>
|
||||
{{t 'resources.storage-bucket.title_plural'}}
|
||||
</nav.link>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if
|
||||
(and
|
||||
|
||||
+23
-10
@@ -4,16 +4,29 @@
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<p>{{t 'resources.session-recording.title'}}
|
||||
{{@model.session_recording_id}}</p>
|
||||
<p>{{t 'resources.session-recording.channel.title'}}
|
||||
{{@model.channel_connection_id}}</p>
|
||||
<Layout::Sidebar as |sb|>
|
||||
<sb.Body>
|
||||
<p>
|
||||
{{t 'resources.session-recording.title'}}
|
||||
{{@model.session_recording_id}}
|
||||
</p>
|
||||
|
||||
<LinkTo
|
||||
@route='scopes.scope.session-recordings.session-recording.channels-by-connection.channel'
|
||||
@model={{@model.channel_connection_id}}
|
||||
>
|
||||
{{@model.channel_connection_id}}
|
||||
</LinkTo>
|
||||
<p>
|
||||
{{t 'resources.session-recording.channel.title'}}
|
||||
{{@model.channel_connection_id}}
|
||||
</p>
|
||||
|
||||
<LinkTo
|
||||
@route='scopes.scope.session-recordings.session-recording.channels-by-connection.channel'
|
||||
@model={{@model.channel_connection_id}}
|
||||
>
|
||||
{{@model.channel_connection_id}}
|
||||
</LinkTo>
|
||||
</sb.Body>
|
||||
|
||||
<sb.Sidebar>
|
||||
<p>{{t 'actions.help'}}</p>
|
||||
</sb.Sidebar>
|
||||
</Layout::Sidebar>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
@@ -1,4 +1,32 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
}}
|
||||
}}
|
||||
|
||||
<Rose::Layout::Page as |page|>
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
{{! TODO: Add valid doc link and description}}
|
||||
<h2>
|
||||
{{t 'resources.storage-bucket.title_plural'}}
|
||||
<DocLink @doc='storage-bucket' @iconSize='large' />
|
||||
</h2>
|
||||
</page.header>
|
||||
|
||||
<page.actions>
|
||||
{{! TODO: Check can create ability using correct file }}
|
||||
{{#if (can 'create model' this.scope collection='storage-buckets')}}
|
||||
{{#if @model}}
|
||||
<Hds::Button
|
||||
@route='scopes.scope.storage-buckets.new'
|
||||
@text={{t 'resources.storage-bucket.titles.new'}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</page.actions>
|
||||
|
||||
<page.body />
|
||||
</Rose::Layout::Page>
|
||||
@@ -117,6 +117,7 @@ module.exports = function (environment) {
|
||||
worker: '/workers',
|
||||
'worker.manage-workers': '/workers/manage-workers-on-hcp',
|
||||
'worker-filters': '/worker-filters',
|
||||
'storage-bucket': '/storage-buckets',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | storage-buckets | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let features;
|
||||
const STORAGE_BUCKET_LINK = 'Storage Buckets';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
storageBuckets: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
urls.globalScope = `/scopes/global`;
|
||||
urls.storageBuckets = `${urls.globalScope}/storage-buckets`;
|
||||
|
||||
features = this.owner.lookup('service:features');
|
||||
features.enable('session-recording');
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('users can navigate to storage-buckets with proper authorization', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
await visit(urls.globalScope);
|
||||
|
||||
assert.true(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('list')
|
||||
);
|
||||
assert.true(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('create')
|
||||
);
|
||||
assert.dom(`[href="${urls.storageBuckets}"]`).exists();
|
||||
});
|
||||
|
||||
test('user cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(3);
|
||||
instances.scopes.global.authorized_collection_actions['storage-buckets'] =
|
||||
[];
|
||||
|
||||
await visit(urls.globalScope);
|
||||
|
||||
assert.false(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('list')
|
||||
);
|
||||
assert.false(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('create')
|
||||
);
|
||||
assert
|
||||
.dom('[title="General"] a:nth-of-type(3)')
|
||||
.doesNotIncludeText(STORAGE_BUCKET_LINK);
|
||||
});
|
||||
|
||||
test('user can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(3);
|
||||
instances.scopes.global.authorized_collection_actions['storage-buckets'] =
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].filter((item) => item !== 'list');
|
||||
|
||||
await visit(urls.globalScope);
|
||||
|
||||
assert.false(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('list')
|
||||
);
|
||||
assert.true(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('create')
|
||||
);
|
||||
assert.dom(`[href="${urls.storageBuckets}"]`).exists();
|
||||
});
|
||||
|
||||
test('user can navigate to index with only list action', async function (assert) {
|
||||
assert.expect(3);
|
||||
instances.scopes.global.authorized_collection_actions['storage-buckets'] =
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].filter((item) => item !== 'create');
|
||||
|
||||
await visit(urls.globalScope);
|
||||
|
||||
assert.true(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('list')
|
||||
);
|
||||
assert.false(
|
||||
instances.scopes.global.authorized_collection_actions[
|
||||
'storage-buckets'
|
||||
].includes('create')
|
||||
);
|
||||
assert.dom(`[href="${urls.storageBuckets}"]`).exists();
|
||||
});
|
||||
|
||||
test('user cannot navigate to index when feature is disabled', async function (assert) {
|
||||
assert.expect(1);
|
||||
features.disable('session-recording');
|
||||
|
||||
await visit(urls.globalScope);
|
||||
|
||||
assert
|
||||
.dom('[title="General"] a:nth-of-type(2)')
|
||||
.doesNotIncludeText(STORAGE_BUCKET_LINK);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, click } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | storage-buckets | read', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let features;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
storageBuckets: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.storageBucket = this.server.create('storage-bucket', {
|
||||
scope: instances.scopes.global,
|
||||
});
|
||||
urls.globalScope = `/scopes/global`;
|
||||
urls.storageBuckets = `${urls.globalScope}/storage-buckets`;
|
||||
|
||||
features = this.owner.lookup('service:features');
|
||||
features.enable('session-recording');
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('visiting storage buckets', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.globalScope);
|
||||
await a11yAudit();
|
||||
|
||||
await click(`[href="${urls.storageBuckets}"]`);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.storageBuckets);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'admin/tests/helpers';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | layout/sidebar', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`
|
||||
<Layout::Sidebar as |sb|>
|
||||
<sb.Body>Body content</sb.Body>
|
||||
<sb.Sidebar>Sidebar content</sb.Sidebar>
|
||||
</Layout::Sidebar>
|
||||
`);
|
||||
|
||||
assert.dom('.layout-sidebar').isVisible();
|
||||
assert.dom('.layout-sidebar-body').isVisible();
|
||||
assert.dom('.layout-sidebar-body').hasText('Body content');
|
||||
assert.dom('.layout-sidebar-sidebar').isVisible();
|
||||
assert.dom('.layout-sidebar-sidebar').hasText('Sidebar content');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'admin/tests/helpers';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | layout/sidebar/body', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`
|
||||
<Layout::Sidebar::Body>
|
||||
template block text
|
||||
</Layout::Sidebar::Body>
|
||||
`);
|
||||
|
||||
assert.dom(this.element).hasText('template block text');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'admin/tests/helpers';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | layout/sidebar/sidebar', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`
|
||||
<Layout::Sidebar::Sidebar>
|
||||
template block text
|
||||
</Layout::Sidebar::Sidebar>
|
||||
`);
|
||||
|
||||
assert.dom(this.element).hasText('template block text');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import {
|
||||
TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
} from 'api/models/storage-bucket';
|
||||
|
||||
module('Unit | Abilities | storage-bucket', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
let features;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
features = this.owner.lookup('service:features');
|
||||
features.enable('session-recording');
|
||||
});
|
||||
|
||||
test('can read storage bucket when authorized and feature is enabled', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const storageBucket = store.createRecord('storage-bucket', {
|
||||
authorized_actions: ['read'],
|
||||
type: TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
|
||||
assert.true(canService.can('read storage-bucket', storageBucket));
|
||||
});
|
||||
|
||||
test('cannot read storage bucket when unauthorized and feature is enabled', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const storageBucket = store.createRecord('storage-bucket', {
|
||||
authorized_actions: [],
|
||||
type: TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
|
||||
assert.false(canService.can('read storage-bucket', storageBucket));
|
||||
});
|
||||
|
||||
test('cannot read storage bucket when authorized and feature is disabled', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
features.disable('session-recording');
|
||||
|
||||
const storageBucket = store.createRecord('storage-bucket', {
|
||||
authorized_actions: ['read'],
|
||||
type: TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
|
||||
assert.false(canService.can('read storage-bucket', storageBucket));
|
||||
});
|
||||
|
||||
test('cannot read storage bucket when unauthorized and feature is disabled', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
features.disable('session-recording');
|
||||
|
||||
const storageBucket = store.createRecord('storage-bucket', {
|
||||
authorized_actions: [],
|
||||
type: TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
|
||||
assert.false(canService.can('read storage-bucket', storageBucket));
|
||||
});
|
||||
|
||||
test('can list storage bucket when authorized and in global scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['list'] },
|
||||
type: 'global',
|
||||
id: 'global',
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can('list storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot list storage bucket when unauthorized and in global scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': [] },
|
||||
type: 'global',
|
||||
id: 'global',
|
||||
});
|
||||
|
||||
assert.false(
|
||||
canService.can('list storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot list storage bucket when authorized and in org scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['list'] },
|
||||
type: 'org',
|
||||
id: 'o_123',
|
||||
});
|
||||
|
||||
assert.false(
|
||||
canService.can('list storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('can create storage bucket when authorized and in global scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['create'] },
|
||||
type: 'global',
|
||||
id: 'global',
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can('create storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('can create storage bucket when authorized and in org scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['create'] },
|
||||
type: 'org',
|
||||
id: 'o_123',
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can('create storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot create storage bucket when authorized and in project scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['create'] },
|
||||
type: 'project',
|
||||
id: 'p_123',
|
||||
});
|
||||
|
||||
assert.false(
|
||||
canService.can('create storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot create storage bucket when unauthorized', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': [] },
|
||||
type: 'global',
|
||||
id: 'global',
|
||||
});
|
||||
|
||||
assert.false(
|
||||
canService.can('create storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('can navigate to storage bucket when authorized', function (assert) {
|
||||
assert.expect(1);
|
||||
const canService = this.owner.lookup('service:can');
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
const scopeModel = store.createRecord('scope', {
|
||||
authorized_collection_actions: { 'storage-buckets': ['create'] },
|
||||
type: 'global',
|
||||
id: 'global',
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can('navigate storage-bucket', scopeModel, {
|
||||
collection: 'storage-buckets',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'admin/tests/helpers';
|
||||
|
||||
module('Unit | Controller | scopes/scope/storage-buckets', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/storage-buckets'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user