Merge branch 'main' into host-catalog-create-list
This commit is contained in:
21 files changed
+488
-125
No files matched your search
+32
-9
@@ -10,9 +10,10 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | groups', function (hooks) {
|
||||
module('Acceptance | groups | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
let orgURL;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -20,9 +21,9 @@ module('Acceptance | groups', function (hooks) {
|
||||
org: null,
|
||||
},
|
||||
group: null,
|
||||
orgScope: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
groups: null,
|
||||
group: null,
|
||||
newGroup: null,
|
||||
@@ -30,17 +31,21 @@ module('Acceptance | groups', function (hooks) {
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.group = this.server.create('group', {
|
||||
scope: instances.scopes.org,
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
urls.groups = `/scopes/${instances.scopes.org.id}/groups`;
|
||||
urls.groups = `/scopes/${instances.orgScope.id}/groups`;
|
||||
urls.group = `${urls.groups}/${instances.group.id}`;
|
||||
urls.newGroup = `${urls.groups}/new`;
|
||||
orgURL = `/scopes/${instances.orgScope.id}`;
|
||||
});
|
||||
|
||||
test('can create new group', async function (assert) {
|
||||
@@ -52,6 +57,24 @@ module('Acceptance | groups', function (hooks) {
|
||||
assert.equal(this.server.db.groups.length, groupsCount + 1);
|
||||
});
|
||||
|
||||
test('can navigate to new groups route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('create')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('cannot navigate to new groups route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.groups = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('create')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
test('can cancel new group creation', async function (assert) {
|
||||
assert.expect(2);
|
||||
const groupsCount = this.server.db.groups.length;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | groups | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
let orgURL;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
},
|
||||
groups: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.group = this.server.create('group', {
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
orgURL = `/scopes/${instances.orgScope.id}`;
|
||||
|
||||
urls.groups = `/scopes/${instances.orgScope.id}/groups`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can navigate to groups with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.groups = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.orgScope.authorized_collection_actions.groups = ['create'];
|
||||
await visit(orgURL);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
});
|
||||
+35
-10
@@ -11,7 +11,7 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | roles', function (hooks) {
|
||||
module('Acceptance | roles | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -22,38 +22,44 @@ module('Acceptance | roles', function (hooks) {
|
||||
project: null,
|
||||
},
|
||||
role: null,
|
||||
orgScope: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
roles: null,
|
||||
role: null,
|
||||
newRole: null,
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
|
||||
// The project scope is not yet used for role tests (though it will be
|
||||
// in the future). This is created simply to test the grant scope loading
|
||||
// mechanism.
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: instances.scopes.org.type },
|
||||
scope: { id: instances.orgScope.id, type: instances.orgScope.type },
|
||||
});
|
||||
instances.role = this.server.create(
|
||||
'role',
|
||||
{
|
||||
scope: instances.scopes.org,
|
||||
scope: instances.orgScope,
|
||||
},
|
||||
'withPrincipals'
|
||||
);
|
||||
urls.roles = `/scopes/${instances.scopes.org.id}/roles`;
|
||||
urls.roles = `/scopes/${instances.orgScope.id}/roles`;
|
||||
urls.role = `${urls.roles}/${instances.role.id}`;
|
||||
urls.newRole = `${urls.roles}/new`;
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}`;
|
||||
});
|
||||
|
||||
test('can create new role', async function (assert) {
|
||||
@@ -65,6 +71,25 @@ module('Acceptance | roles', function (hooks) {
|
||||
assert.equal(this.server.db.roles.length, rolesCount + 1);
|
||||
});
|
||||
|
||||
test('Users can navigate to new roles route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.roles.includes('create')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.roles}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new roles route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.roles = [];
|
||||
await visit(urls.orgScope);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.roles.includes('create')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.roles}"]`));
|
||||
});
|
||||
|
||||
test('can cancel new role creation', async function (assert) {
|
||||
assert.expect(2);
|
||||
const rolesCount = this.server.db.roles.length;
|
||||
@@ -0,0 +1,75 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | roles | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
},
|
||||
roles: null,
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.role = this.server.create('role', {
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}`;
|
||||
|
||||
urls.roles = `/scopes/${instances.orgScope.id}/roles`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can navigate to roles with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.roles.includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.roles}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.roles = [];
|
||||
await visit(urls.orgScope);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.roles.includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.roles}"]`));
|
||||
});
|
||||
|
||||
test('Users can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.orgScope.authorized_collection_actions.roles = ['create'];
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(find(`[href="${urls.roles}"]`));
|
||||
});
|
||||
});
|
||||
+21
-1
@@ -10,11 +10,12 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | users', function (hooks) {
|
||||
module('Acceptance | users | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let orgScope;
|
||||
let orgURL;
|
||||
let usersURL;
|
||||
let newUserURL;
|
||||
|
||||
@@ -23,10 +24,12 @@ module('Acceptance | users', function (hooks) {
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
|
||||
orgURL = `/scopes/${orgScope.id}`;
|
||||
usersURL = `/scopes/${orgScope.id}/users`;
|
||||
newUserURL = `${usersURL}/new`;
|
||||
|
||||
@@ -42,6 +45,23 @@ module('Acceptance | users', function (hooks) {
|
||||
assert.equal(this.server.db.users.length, usersCount + 1);
|
||||
});
|
||||
|
||||
test('can navigate to new users route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(orgScope.authorized_collection_actions.users.includes('create'));
|
||||
assert.ok(find(`[href="${orgURL}/users"]`));
|
||||
});
|
||||
|
||||
test('cannot navigate to new users route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
orgScope.authorized_collection_actions.users = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
orgScope.authorized_collection_actions.users.includes('create')
|
||||
);
|
||||
assert.notOk(find(`[href="${orgURL}/users"]`));
|
||||
});
|
||||
|
||||
test('can cancel creation of a new user', async function (assert) {
|
||||
assert.expect(2);
|
||||
const usersCount = this.server.db.users.length;
|
||||
@@ -0,0 +1,75 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | users | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
let orgURL;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
},
|
||||
users: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.user = this.server.create('user', {
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
orgURL = `/scopes/${instances.orgScope.id}`;
|
||||
urls.users = `/scopes/${instances.orgScope.id}/users`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can navigate to users with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.users.includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.users}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.users = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.users.includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.users}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.orgScope.authorized_collection_actions.users = ['create'];
|
||||
await visit(orgURL);
|
||||
assert.ok(find(`[href="${urls.users}"]`));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user