mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* basic-functionality demo for token CRUD * Styling for tokens crud * Tokens crud styles * Expires, not expiry * Mobile styles etc * Refresh and redirect rules for policy save and token creation * Delete method and associated serializer change * Ability-checking for tokens * Update policies acceptance tests to reflect new redirect rules * Token ability unit tests * Mirage config methods for token crud * Token CRUD acceptance tests * A couple visual diff snapshots * Add and Delete abilities referenced for token operations * Changing timeouts and adding a copy to clipboard action * replaced accessor with secret when copying to clipboard * PR comments addressed * Simplified error passing for policy editor
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
/* eslint-disable ember/avoid-leaking-state-in-ember-objects */
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
import Service from '@ember/service';
|
|
import setupAbility from 'nomad-ui/tests/helpers/setup-ability';
|
|
|
|
module('Unit | Ability | token', function (hooks) {
|
|
setupTest(hooks);
|
|
setupAbility('token')(hooks);
|
|
|
|
test('A non-management user can do nothing with tokens', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'client' },
|
|
});
|
|
this.owner.register('service:token', mockToken);
|
|
assert.notOk(this.ability.canRead);
|
|
assert.notOk(this.ability.canList);
|
|
assert.notOk(this.ability.canWrite);
|
|
assert.notOk(this.ability.canUpdate);
|
|
assert.notOk(this.ability.canDestroy);
|
|
});
|
|
|
|
test('A management user can do everything with tokens', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'management' },
|
|
});
|
|
this.owner.register('service:token', mockToken);
|
|
assert.ok(this.ability.canRead);
|
|
assert.ok(this.ability.canList);
|
|
assert.ok(this.ability.canWrite);
|
|
assert.ok(this.ability.canUpdate);
|
|
assert.ok(this.ability.canDestroy);
|
|
});
|
|
|
|
test('A non-ACL agent (bypassAuthorization) does not allow anything', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: false,
|
|
});
|
|
this.owner.register('service:token', mockToken);
|
|
assert.notOk(this.ability.canRead);
|
|
assert.notOk(this.ability.canList);
|
|
assert.notOk(this.ability.canWrite);
|
|
assert.notOk(this.ability.canUpdate);
|
|
assert.notOk(this.ability.canDestroy);
|
|
});
|
|
});
|