mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
* variables.new initialized * Hacky but savey * Variable wildcard route and multiple creatable at a time * multiple KVs per variable * PR Prep cleanup and lintfix * Delog * Data mocking in mirage for variables * Linting fixes * Re-implement absent params * Adapter and model tests * Moves the path-as-id logic to a serializer instead of adapter * Classic to serializer and lint cleanup * Pluralized save button (#13140) * Autofocus modifier and better Add More button UX (#13145) * Secure Variables: show/hide functionality when adding new values (#13137) * Flight Icons added and show hide functionality * PR cleanup * Linting cleanup * Position of icon moved to the right of input * PR feedback addressed * Delete button and stylistic changes to show hide * Hmm, eslint doesnt like jsdoc-usage as only reason for import * More closely match the button styles and delete test * Simplified new.js model * Secure Variables: /variables/*path/edit route and functionality (#13170) * Variable edit page init * Significant change to where we house model methods * Lintfix * Edit a variable tests * Remove redundant tests * Asserts expected * Mirage factory updated to reflect model state
102 lines
2.6 KiB
JavaScript
102 lines
2.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 | variable', function (hooks) {
|
|
setupTest(hooks);
|
|
setupAbility('variable')(hooks);
|
|
hooks.beforeEach(function () {
|
|
const mockSystem = Service.extend({
|
|
features: [],
|
|
});
|
|
|
|
this.owner.register('service:system', mockSystem);
|
|
});
|
|
|
|
test('it does not permit listing variables by default', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
});
|
|
|
|
this.owner.register('service:token', mockToken);
|
|
|
|
assert.notOk(this.ability.canList);
|
|
});
|
|
|
|
test('it does not permit listing variables when token type is client', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'client' },
|
|
});
|
|
|
|
this.owner.register('service:token', mockToken);
|
|
|
|
assert.notOk(this.ability.canList);
|
|
});
|
|
|
|
test('it permits listing variables when token type is management', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'management' },
|
|
});
|
|
|
|
this.owner.register('service:token', mockToken);
|
|
|
|
assert.ok(this.ability.canList);
|
|
});
|
|
|
|
test('it permits listing variables when token has SecureVariables with list capabilities in its rules', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'client' },
|
|
selfTokenPolicies: [
|
|
{
|
|
rulesJSON: {
|
|
Namespaces: [
|
|
{
|
|
Name: 'default',
|
|
Capabilities: [],
|
|
SecureVariables: {
|
|
'Path "*"': {
|
|
Capabilities: ['list'],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
});
|
|
|
|
this.owner.register('service:token', mockToken);
|
|
|
|
assert.ok(this.ability.canList);
|
|
});
|
|
|
|
test('it permits listing variables when token has SecureVariables alone in its rules', function (assert) {
|
|
const mockToken = Service.extend({
|
|
aclEnabled: true,
|
|
selfToken: { type: 'client' },
|
|
selfTokenPolicies: [
|
|
{
|
|
rulesJSON: {
|
|
Namespaces: [
|
|
{
|
|
Name: 'default',
|
|
Capabilities: [],
|
|
SecureVariables: {},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
});
|
|
|
|
this.owner.register('service:token', mockToken);
|
|
|
|
assert.ok(this.ability.canList);
|
|
});
|
|
});
|