mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Merge pull request #14383 from hashicorp/variables-rename-ui
[ui] Variables Rename
This commit is contained in:
@@ -48,7 +48,7 @@ export default class Variable extends AbstractAbility {
|
||||
|
||||
@computed('token.selfTokenPolicies')
|
||||
get policiesSupportVariableList() {
|
||||
return this.policyNamespacesIncludeSecureVariablesCapabilities(
|
||||
return this.policyNamespacesIncludeVariablesCapabilities(
|
||||
this.token.selfTokenPolicies,
|
||||
['list', 'read', 'write', 'destroy']
|
||||
);
|
||||
@@ -65,7 +65,7 @@ export default class Variable extends AbstractAbility {
|
||||
/**
|
||||
*
|
||||
* Map to your policy's namespaces,
|
||||
* and each of their SecureVariables blocks' paths,
|
||||
* and each of their Variables blocks' paths,
|
||||
* and each of their capabilities.
|
||||
* Then, check to see if any of the permissions you're looking for
|
||||
* are contained within at least one of them.
|
||||
@@ -74,36 +74,36 @@ export default class Variable extends AbstractAbility {
|
||||
* @param {string[]} capabilities
|
||||
* @returns {boolean}
|
||||
*/
|
||||
policyNamespacesIncludeSecureVariablesCapabilities(
|
||||
policyNamespacesIncludeVariablesCapabilities(
|
||||
policies = [],
|
||||
capabilities = [],
|
||||
path
|
||||
) {
|
||||
const namespacesWithSecureVariableCapabilities = policies
|
||||
const namespacesWithVariableCapabilities = policies
|
||||
.toArray()
|
||||
.filter((policy) => get(policy, 'rulesJSON.Namespaces'))
|
||||
.map((policy) => get(policy, 'rulesJSON.Namespaces'))
|
||||
.flat()
|
||||
.map((namespace = {}) => {
|
||||
return namespace.SecureVariables?.Paths;
|
||||
return namespace.Variables?.Paths;
|
||||
})
|
||||
.flat()
|
||||
.compact()
|
||||
.filter((secVarsBlock = {}) => {
|
||||
.filter((varsBlock = {}) => {
|
||||
if (!path || path === WILDCARD_GLOB) {
|
||||
return true;
|
||||
} else {
|
||||
return secVarsBlock.PathSpec === path;
|
||||
return varsBlock.PathSpec === path;
|
||||
}
|
||||
})
|
||||
.map((secVarsBlock = {}) => {
|
||||
return secVarsBlock.Capabilities;
|
||||
.map((varsBlock = {}) => {
|
||||
return varsBlock.Capabilities;
|
||||
})
|
||||
.flat()
|
||||
.compact();
|
||||
|
||||
// Check for requested permissions
|
||||
return namespacesWithSecureVariableCapabilities.some((abilityList) => {
|
||||
return namespacesWithVariableCapabilities.some((abilityList) => {
|
||||
return capabilities.includes(abilityList);
|
||||
});
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export default class Variable extends AbstractAbility {
|
||||
if (this.namespace === WILDCARD_GLOB && this.path === WILDCARD_GLOB) {
|
||||
// If you're checking if you can write from root, and you don't specify a namespace,
|
||||
// Then if you can write in ANY path in ANY namespace, you can get to /new.
|
||||
return this.policyNamespacesIncludeSecureVariablesCapabilities(
|
||||
return this.policyNamespacesIncludeVariablesCapabilities(
|
||||
this.token.selfTokenPolicies,
|
||||
['write'],
|
||||
this._nearestMatchingPath(this.path)
|
||||
@@ -150,7 +150,7 @@ export default class Variable extends AbstractAbility {
|
||||
|
||||
const variables = (namespaces || []).find(
|
||||
(namespace) => namespace.Name === matchingNamespace
|
||||
)?.SecureVariables;
|
||||
)?.Variables;
|
||||
|
||||
const pathNames = variables?.Paths?.map((path) => ({
|
||||
name: path.PathSpec,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{{did-update this.onViewChange @view}}
|
||||
{{did-insert this.establishKeyValues}}
|
||||
<form class="new-secure-variables" autocomplete="off" {{on "submit" this.save}}>
|
||||
<form class="new-variables" autocomplete="off" {{on "submit" this.save}}>
|
||||
|
||||
{{#if @model.isNew}}
|
||||
<div class="related-entities related-entities-hint">
|
||||
<p>Prefix your path with <code>nomad/jobs/</code> to automatically make your secure variable accessible to a specified job, task group, or task.<br />
|
||||
<p>Prefix your path with <code>nomad/jobs/</code> to automatically make your variable accessible to a specified job, task group, or task.<br />
|
||||
Format: <code>nomad/jobs/<jobname></code>, <code>nomad/jobs/<jobname>/<groupname></code>, <code>nomad/jobs/<jobname>/<groupname>/<taskname></code></p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.hasConflict}}
|
||||
<div class="notification conflict is-danger">
|
||||
<h3 class="title is-4">Heads up! Your Secure Variable has a conflict.</h3>
|
||||
<h3 class="title is-4">Heads up! Your variable has a conflict.</h3>
|
||||
<p>This might be because someone else tried saving in the time since you've had it open.</p>
|
||||
{{#if this.conflictingVariable.modifyTime}}
|
||||
<span class="tooltip" aria-label="{{format-ts this.conflictingVariable.modifyTime}}">
|
||||
@@ -46,7 +46,7 @@
|
||||
/>
|
||||
{{#if this.duplicatePathWarning}}
|
||||
<p class="duplicate-path-error help is-danger">
|
||||
There is already a Secure Variable located at
|
||||
There is already a variable located at
|
||||
{{this.path}}
|
||||
.
|
||||
<br />
|
||||
@@ -55,13 +55,13 @@
|
||||
@route="variables.variable.edit"
|
||||
@model={{this.duplicatePathWarning.path}}
|
||||
>
|
||||
edit the existing Secure Variable
|
||||
edit the existing variable
|
||||
</LinkTo>
|
||||
.
|
||||
</p>
|
||||
{{/if}}
|
||||
</label>
|
||||
<SecureVariableForm::NamespaceFilter
|
||||
<VariableForm::NamespaceFilter
|
||||
@data={{hash
|
||||
disabled=(not @model.isNew)
|
||||
selection=this.variableNamespace
|
||||
@@ -108,7 +108,7 @@
|
||||
{{on "input" (fn this.validateKey entry)}}
|
||||
/>
|
||||
</label>
|
||||
<SecureVariableForm::InputGroup @entry={{entry}} />
|
||||
<VariableForm::InputGroup @entry={{entry}} />
|
||||
{{#if (eq entry this.keyValues.lastObject)}}
|
||||
<button
|
||||
class="add-more button is-info is-inverted"
|
||||
@@ -137,7 +137,7 @@
|
||||
{{/if}}
|
||||
|
||||
{{#if (and this.shouldShowLinkedEntities @model.isNew)}}
|
||||
<SecureVariableForm::RelatedEntities
|
||||
<VariableForm::RelatedEntities
|
||||
@new={{true}}
|
||||
@job={{@model.pathLinkedEntities.job}}
|
||||
@group={{@model.pathLinkedEntities.group}}
|
||||
@@ -19,7 +19,7 @@ const EMPTY_KV = {
|
||||
warnings: EmberObject.create(),
|
||||
};
|
||||
|
||||
export default class SecureVariableFormComponent extends Component {
|
||||
export default class VariableFormComponent extends Component {
|
||||
@service flashMessages;
|
||||
@service router;
|
||||
@service store;
|
||||
@@ -200,7 +200,7 @@ export default class SecureVariableFormComponent extends Component {
|
||||
await this.args.model.save({ adapterOptions: { overwrite } });
|
||||
|
||||
this.flashMessages.add({
|
||||
title: 'Secure Variable saved',
|
||||
title: 'Variable saved',
|
||||
message: `${this.path} successfully saved`,
|
||||
type: 'success',
|
||||
destroyOnClick: false,
|
||||
@@ -302,15 +302,13 @@ export default class SecureVariableFormComponent extends Component {
|
||||
throw new Error('Invalid JSON');
|
||||
}
|
||||
|
||||
// "myString" is valid JSON, but it's not a valid Secure Variable.
|
||||
// Ditto for an array of objects. We expect a single object to be a Secure Variable.
|
||||
// "myString" is valid JSON, but it's not a valid Variable.
|
||||
// Ditto for an array of objects. We expect a single object to be a Variable.
|
||||
const hasFormatErrors =
|
||||
JSON.parse(value) instanceof Array ||
|
||||
typeof JSON.parse(value) !== 'object';
|
||||
if (hasFormatErrors) {
|
||||
throw new Error(
|
||||
'A Secure Variable must be formatted as a single JSON object'
|
||||
);
|
||||
throw new Error('A Variable must be formatted as a single JSON object');
|
||||
}
|
||||
|
||||
set(this, 'JSONError', null);
|
||||
@@ -1,7 +1,7 @@
|
||||
<p class="related-entities notification">
|
||||
<FlightIcon @name="info-fill" @color="var(--blue)" />
|
||||
<span>
|
||||
This secure variable {{#if @new}}will be{{else}}is{{/if}} accessible by
|
||||
This variable {{#if @new}}will be{{else}}is{{/if}} accessible by
|
||||
{{#if @task}}
|
||||
task <strong>{{@task}}</strong> in group <LinkTo @route="jobs.job.task-group" @models={{array (concat @job "@" @namespace) @group}}>{{@group}} <FlightIcon @name="external-link" /></LinkTo>
|
||||
{{else if @group}}
|
||||
@@ -40,7 +40,7 @@ export default class VariablesVariableIndexController extends Controller {
|
||||
this.router.transitionTo('variables');
|
||||
}
|
||||
this.flashMessages.add({
|
||||
title: 'Secure Variable deleted',
|
||||
title: 'Variable deleted',
|
||||
message: `${this.model.path} successfully deleted`,
|
||||
type: 'success',
|
||||
destroyOnClick: false,
|
||||
|
||||
@@ -15,12 +15,12 @@ import { attr } from '@ember-data/model';
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef SecureVariable
|
||||
* @typedef Variable
|
||||
* @type {object}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Secure Variable has a path, namespace, and an array of key-value pairs within the client.
|
||||
* A Variable has a path, namespace, and an array of key-value pairs within the client.
|
||||
* On the server, these key-value pairs are serialized into object structure.
|
||||
* @class
|
||||
* @extends Model
|
||||
|
||||
@@ -46,5 +46,5 @@
|
||||
@import './components/tooltip';
|
||||
@import './components/two-step-button';
|
||||
@import './components/evaluations';
|
||||
@import './components/secure-variables';
|
||||
@import './components/variables';
|
||||
@import './components/keyboard-shortcuts-modal';
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.new-secure-variables {
|
||||
.new-variables {
|
||||
& > div {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Breadcrumb @crumb={{hash label="Secure Variables" args=(array "variables.index")}} />
|
||||
<Breadcrumb @crumb={{hash label="Variables" args=(array "variables.index")}} />
|
||||
<PageLayout>
|
||||
{{outlet}}
|
||||
</PageLayout>
|
||||
@@ -1,4 +1,4 @@
|
||||
{{page-title "Secure Variables"}}
|
||||
{{page-title "Variables"}}
|
||||
<section class="section">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-item is-right-aligned is-mobile-full-width">
|
||||
@@ -18,7 +18,7 @@
|
||||
class="button is-primary"
|
||||
data-test-create-var
|
||||
>
|
||||
Create Secure Variable
|
||||
Create Variable
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
<button
|
||||
@@ -28,7 +28,7 @@
|
||||
type="button"
|
||||
data-test-disabled-create-var
|
||||
>
|
||||
Create Secure Variable
|
||||
Create Variable
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
<div class="empty-message">
|
||||
{{#if (eq this.namespaceSelection "*")}}
|
||||
<h3 data-test-empty-variables-list-headline class="empty-message-headline">
|
||||
No Secure Variables
|
||||
No Variables
|
||||
</h3>
|
||||
{{#if (can "write variable" path="*" namespace=this.namespaceSelection)}}
|
||||
<p class="empty-message-body">
|
||||
Get started by <LinkTo @route="variables.new">creating a new secure variable</LinkTo>
|
||||
Get started by <LinkTo @route="variables.new">creating a new variable</LinkTo>
|
||||
</p>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{{page-title "New Secure Variable"}}
|
||||
{{page-title "New Variable"}}
|
||||
<Breadcrumb @crumb={{hash label="New" args=(array "variables.new")}} />
|
||||
|
||||
<section class="section">
|
||||
<h1 class="title variable-title">
|
||||
Create a Secure Variable
|
||||
Create a Variable
|
||||
<Toggle
|
||||
data-test-memory-toggle
|
||||
@isActive={{eq this.view "json"}}
|
||||
@@ -12,7 +12,7 @@
|
||||
>JSON</Toggle>
|
||||
</h1>
|
||||
|
||||
<SecureVariableForm
|
||||
<VariableForm
|
||||
@model={{this.model}}
|
||||
@path={{this.path}}
|
||||
@existingVariables={{this.existingVariables}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{page-title "Secure Variables: " this.absolutePath}}
|
||||
{{page-title "Variables: " this.absolutePath}}
|
||||
{{#each this.breadcrumbs as |crumb|}}
|
||||
<Breadcrumb @crumb={{crumb}} />
|
||||
{{/each}}
|
||||
@@ -21,7 +21,7 @@
|
||||
@query={{hash path=(concat this.absolutePath "/")}}
|
||||
class="button is-primary"
|
||||
>
|
||||
Create Secure Variable
|
||||
Create Variable
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
<button
|
||||
@@ -30,7 +30,7 @@
|
||||
disabled
|
||||
type="button"
|
||||
>
|
||||
Create Secure Variable
|
||||
Create Variable
|
||||
</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
@@ -50,7 +50,7 @@
|
||||
Path /{{this.absolutePath}} contains no variables
|
||||
</h3>
|
||||
<p class="empty-message-body">
|
||||
To get started, <LinkTo @route="variables.new" @query={{hash path=(concat this.absolutePath "/")}}>create a new secure variable here</LinkTo>, or <LinkTo @route="variables">go back to the Secure Variables root directory</LinkTo>.
|
||||
To get started, <LinkTo @route="variables.new" @query={{hash path=(concat this.absolutePath "/")}}>create a new variable here</LinkTo>, or <LinkTo @route="variables">go back to the Variables root directory</LinkTo>.
|
||||
</p>
|
||||
{{else}}
|
||||
<h3 data-test-no-matching-variables-list-headline class="empty-message-headline">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{page-title "Secure Variables: " this.model.path}}
|
||||
{{page-title "Variables: " this.model.path}}
|
||||
{{#each this.breadcrumbs as |crumb|}}
|
||||
<Breadcrumb @crumb={{crumb}} />
|
||||
{{/each}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{page-title "Edit Secure Variable"}}
|
||||
{{page-title "Edit Variable"}}
|
||||
|
||||
<h1 class="title variable-title">
|
||||
<LinkTo class="back-link" @route="variables.variable.index">
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
</h1>
|
||||
|
||||
<SecureVariableForm
|
||||
<VariableForm
|
||||
@model={{this.model}}
|
||||
@existingVariables={{this.existingVariables}}
|
||||
@view={{this.view}}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</h1>
|
||||
|
||||
{{#if this.shouldShowLinkedEntities}}
|
||||
<SecureVariableForm::RelatedEntities
|
||||
<VariableForm::RelatedEntities
|
||||
@job={{this.model.pathLinkedEntities.job}}
|
||||
@group={{this.model.pathLinkedEntities.group}}
|
||||
@task={{this.model.pathLinkedEntities.task}}
|
||||
|
||||
@@ -10,9 +10,9 @@ import { trimPath } from '../helpers/trim-path';
|
||||
/**
|
||||
* @typedef {Object} VariableFile
|
||||
* @property {string} path - the folder path containing our "file", relative to parent
|
||||
* @property {string} name - the secure variable "file" name
|
||||
* @property {string} name - the variable "file" name
|
||||
* @property {string} absoluteFilePath - the folder path containing our "file", absolute
|
||||
* @property {VariableModel} variable - the secure variable itself
|
||||
* @property {VariableModel} variable - the variable itself
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -837,7 +837,7 @@ export default function () {
|
||||
}
|
||||
);
|
||||
|
||||
//#region Secure Variables
|
||||
//#region Variables
|
||||
|
||||
this.get('/vars', function (schema, { queryParams: { namespace } }) {
|
||||
if (namespace && namespace !== '*') {
|
||||
@@ -883,7 +883,7 @@ export default function () {
|
||||
return '';
|
||||
});
|
||||
|
||||
//#endregion Secure Variables
|
||||
//#endregion Variables
|
||||
}
|
||||
|
||||
function filterKeys(object, ...keys) {
|
||||
|
||||
@@ -28,7 +28,7 @@ export default Factory.extend({
|
||||
|
||||
token.update({ policyIds });
|
||||
|
||||
// Create a special policy with secure variables rules in place
|
||||
// Create a special policy with variables rules in place
|
||||
if (token.id === '53cur3-v4r14bl35') {
|
||||
const variableMakerPolicy = {
|
||||
id: 'Variable Maker',
|
||||
@@ -37,8 +37,8 @@ export default Factory.extend({
|
||||
namespace "*" {
|
||||
policy = "read"
|
||||
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
||||
secure_variables {
|
||||
# Base access is to all abilities for all secure variables
|
||||
variables {
|
||||
# Base access is to all abilities for all variables
|
||||
path "*" {
|
||||
capabilities = ["list", "read", "destroy", "create"]
|
||||
}
|
||||
@@ -55,7 +55,7 @@ node {
|
||||
{
|
||||
Name: '*',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -78,8 +78,8 @@ node {
|
||||
namespace "*" {
|
||||
policy = "read"
|
||||
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
||||
secure_variables {
|
||||
# Base access is to all abilities for all secure variables
|
||||
variables {
|
||||
# Base access is to all abilities for all variables
|
||||
path "*" {
|
||||
capabilities = ["list"]
|
||||
}
|
||||
@@ -89,8 +89,8 @@ namespace "*" {
|
||||
namespace "namespace-1" {
|
||||
policy = "read"
|
||||
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
||||
secure_variables {
|
||||
# Base access is to all abilities for all secure variables
|
||||
variables {
|
||||
# Base access is to all abilities for all variables
|
||||
path "*" {
|
||||
capabilities = ["list", "read", "destroy", "create"]
|
||||
}
|
||||
@@ -100,8 +100,8 @@ namespace "namespace-1" {
|
||||
namespace "namespace-2" {
|
||||
policy = "read"
|
||||
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
||||
secure_variables {
|
||||
# Base access is to all abilities for all secure variables
|
||||
variables {
|
||||
# Base access is to all abilities for all variables
|
||||
path "blue/*" {
|
||||
capabilities = ["list", "read", "destroy", "create"]
|
||||
}
|
||||
@@ -121,7 +121,7 @@ node {
|
||||
{
|
||||
Name: '*',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list'],
|
||||
@@ -133,7 +133,7 @@ node {
|
||||
{
|
||||
Name: 'namespace-1',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list', 'read', 'destroy', 'create'],
|
||||
@@ -145,7 +145,7 @@ node {
|
||||
{
|
||||
Name: 'namespace-2',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list', 'read', 'destroy', 'create'],
|
||||
|
||||
@@ -22,8 +22,8 @@ import percySnapshot from '@percy/ember';
|
||||
import Variables from 'nomad-ui/tests/pages/variables';
|
||||
import Layout from 'nomad-ui/tests/pages/layout';
|
||||
|
||||
const SECURE_TOKEN_ID = '53cur3-v4r14bl35';
|
||||
const LIMITED_SECURE_TOKEN_ID = 'f3w3r-53cur3-v4r14bl35';
|
||||
const VARIABLE_TOKEN_ID = '53cur3-v4r14bl35';
|
||||
const LIMITED_VARIABLE_TOKEN_ID = 'f3w3r-53cur3-v4r14bl35';
|
||||
|
||||
module('Acceptance | secure variables', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -49,7 +49,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('it allows access for list-variables allowed ACL rules', async function (assert) {
|
||||
assert.expect(2);
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
|
||||
await Variables.visit();
|
||||
@@ -61,11 +61,11 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('it correctly traverses to and deletes a variable', async function (assert) {
|
||||
assert.expect(13);
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
server.db.variables.update({ namespace: 'default' });
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list', 'read', 'destroy'];
|
||||
|
||||
@@ -145,7 +145,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('variables prefixed with nomad/jobs/ correctly link to entities', async function (assert) {
|
||||
assert.expect(23);
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
|
||||
const variableLinkedJob = server.db.jobs[0];
|
||||
const variableLinkedGroup = server.db.taskGroups.findBy({
|
||||
@@ -207,7 +207,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
assert.dom(relatedEntitiesBox).exists('Related Entities box is present');
|
||||
assert.ok(
|
||||
cleanWhitespace(relatedEntitiesBox.textContent).includes(
|
||||
'This secure variable is accessible by job'
|
||||
'This variable is accessible by job'
|
||||
),
|
||||
'Related Entities box is job-oriented'
|
||||
);
|
||||
@@ -243,7 +243,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
assert.dom(relatedEntitiesBox).exists('Related Entities box is present');
|
||||
assert.ok(
|
||||
cleanWhitespace(relatedEntitiesBox.textContent).includes(
|
||||
'This secure variable is accessible by group'
|
||||
'This variable is accessible by group'
|
||||
),
|
||||
'Related Entities box is group-oriented'
|
||||
);
|
||||
@@ -281,7 +281,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
assert.dom(relatedEntitiesBox).exists('Related Entities box is present');
|
||||
assert.ok(
|
||||
cleanWhitespace(relatedEntitiesBox.textContent).includes(
|
||||
'This secure variable is accessible by task'
|
||||
'This variable is accessible by task'
|
||||
),
|
||||
'Related Entities box is task-oriented'
|
||||
);
|
||||
@@ -342,27 +342,25 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('it passes an accessibility audit', async function (assert) {
|
||||
assert.expect(1);
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
await a11yAudit(assert);
|
||||
});
|
||||
|
||||
module('create flow', function () {
|
||||
test('allows a user with correct permissions to create a secure variable', async function (assert) {
|
||||
test('allows a user with correct permissions to create a variable', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
// End Test Set-up
|
||||
|
||||
assert
|
||||
.dom('[data-test-create-var]')
|
||||
.exists(
|
||||
'It should display an enabled button to create a secure variable'
|
||||
);
|
||||
.exists('It should display an enabled button to create a variable');
|
||||
await click('[data-test-create-var]');
|
||||
|
||||
assert.equal(currentRouteName(), 'variables.new');
|
||||
@@ -402,14 +400,14 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
window.localStorage.nomadTokenSecret = null;
|
||||
});
|
||||
|
||||
test('prevents users from creating a secure variable without proper permissions', async function (assert) {
|
||||
test('prevents users from creating a variable without proper permissions', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list'];
|
||||
await Variables.visit();
|
||||
@@ -418,7 +416,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
assert
|
||||
.dom('[data-test-disabled-create-var]')
|
||||
.exists(
|
||||
'It should display an disabled button to create a secure variable on the main listings page'
|
||||
'It should display an disabled button to create a variable on the main listings page'
|
||||
);
|
||||
|
||||
// Reset Token
|
||||
@@ -429,7 +427,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visitNew();
|
||||
// End Test Set-up
|
||||
@@ -456,7 +454,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visitNew();
|
||||
// End Test Set-up
|
||||
@@ -476,15 +474,15 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
});
|
||||
|
||||
module('edit flow', function () {
|
||||
test('allows a user with correct permissions to edit a secure variable', async function (assert) {
|
||||
test('allows a user with correct permissions to edit a variable', async function (assert) {
|
||||
assert.expect(8);
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list', 'read', 'write'];
|
||||
server.db.variables.update({ namespace: 'default' });
|
||||
@@ -531,14 +529,14 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
window.localStorage.nomadTokenSecret = null;
|
||||
});
|
||||
|
||||
test('prevents users from editing a secure variable without proper permissions', async function (assert) {
|
||||
test('prevents users from editing a variable without proper permissions', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list', 'read'];
|
||||
await Variables.visit();
|
||||
@@ -556,7 +554,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('handles conflicts on save', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
// End Test Set-up
|
||||
|
||||
@@ -593,14 +591,14 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
});
|
||||
|
||||
module('delete flow', function () {
|
||||
test('allows a user with correct permissions to delete a secure variable', async function (assert) {
|
||||
test('allows a user with correct permissions to delete a variable', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list', 'read', 'destroy'];
|
||||
server.db.variables.update({ namespace: 'default' });
|
||||
@@ -629,14 +627,14 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
window.localStorage.nomadTokenSecret = null;
|
||||
});
|
||||
|
||||
test('prevents users from delete a secure variable without proper permissions', async function (assert) {
|
||||
test('prevents users from delete a variable without proper permissions', async function (assert) {
|
||||
// Arrange Test Set-up
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const policy = server.db.policies.find('Variable Maker');
|
||||
policy.rulesJSON.Namespaces[0].SecureVariables.Paths.find(
|
||||
policy.rulesJSON.Namespaces[0].Variables.Paths.find(
|
||||
(path) => path.PathSpec === '*'
|
||||
).Capabilities = ['list', 'read'];
|
||||
await Variables.visit();
|
||||
@@ -654,9 +652,9 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
});
|
||||
|
||||
module('read flow', function () {
|
||||
test('allows a user with correct permissions to read a secure variable', async function (assert) {
|
||||
test('allows a user with correct permissions to read a variable', async function (assert) {
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
|
||||
@@ -674,9 +672,9 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
window.localStorage.nomadTokenSecret = null;
|
||||
});
|
||||
|
||||
test('prevents users from reading a secure variable without proper permissions', async function (assert) {
|
||||
test('prevents users from reading a variable without proper permissions', async function (assert) {
|
||||
allScenarios.variableTestCluster(server);
|
||||
const variablesToken = server.db.tokens.find(LIMITED_SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(LIMITED_VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
|
||||
@@ -699,7 +697,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
// Arrange
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
|
||||
@@ -731,7 +729,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('does not show namespace filtering if the user only has access to one namespace', async function (assert) {
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const twoTokens = server.db.namespaces.slice(0, 2);
|
||||
server.db.namespaces.remove(twoTokens);
|
||||
@@ -754,7 +752,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
// Arrange
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
await Variables.visit();
|
||||
await click('[data-test-folder-row]');
|
||||
@@ -793,7 +791,7 @@ module('Acceptance | secure variables', function (hooks) {
|
||||
test('does not show namespace filtering if the user only has access to one namespace', async function (assert) {
|
||||
allScenarios.variableTestCluster(server);
|
||||
server.createList('variable', 3);
|
||||
const variablesToken = server.db.tokens.find(SECURE_TOKEN_ID);
|
||||
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
|
||||
window.localStorage.nomadTokenSecret = variablesToken.secretId;
|
||||
const twoTokens = server.db.namespaces.slice(0, 2);
|
||||
server.db.namespaces.remove(twoTokens);
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
clickTrigger,
|
||||
} from 'ember-power-select/test-support/helpers';
|
||||
|
||||
module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
module('Integration | Component | variable-form', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
setupMirage(hooks);
|
||||
setupCodeMirror(hooks);
|
||||
@@ -25,7 +25,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
keyValues: [{ key: '', value: '' }],
|
||||
})
|
||||
);
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
await componentA11yAudit(this.element, assert);
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
);
|
||||
assert.expect(7);
|
||||
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
assert.equal(
|
||||
findAll('div.key-value').length,
|
||||
1,
|
||||
@@ -106,7 +106,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
|
||||
assert.expect(6);
|
||||
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
await click('.key-value button.add-more'); // add a second variable
|
||||
|
||||
findAll('input.value-input').forEach((input, iter) => {
|
||||
@@ -163,7 +163,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
keyValues,
|
||||
})
|
||||
);
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
assert.equal(
|
||||
findAll('div.key-value').length,
|
||||
5,
|
||||
@@ -206,7 +206,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
});
|
||||
variable.isNew = false;
|
||||
this.set('variable', variable);
|
||||
await render(hbs`<SecureVariableForm @model={{this.variable}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.variable}} />`);
|
||||
assert.dom('input.path-input').hasValue('/baz/bat', 'Path is set');
|
||||
assert
|
||||
.dom('input.path-input')
|
||||
@@ -215,7 +215,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
variable.isNew = true;
|
||||
variable.path = '';
|
||||
this.set('variable', variable);
|
||||
await render(hbs`<SecureVariableForm @model={{this.variable}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.variable}} />`);
|
||||
assert
|
||||
.dom('input.path-input')
|
||||
.isNotDisabled('New variable is not in disabled state');
|
||||
@@ -244,7 +244,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
this.set('existingVariables', server.db.variables.toArray());
|
||||
|
||||
await render(
|
||||
hbs`<SecureVariableForm @model={{this.mockedModel}} @existingVariables={{this.existingVariables}} />`
|
||||
hbs`<VariableForm @model={{this.mockedModel}} @existingVariables={{this.existingVariables}} />`
|
||||
);
|
||||
|
||||
await typeIn('.path-input', 'foo/bar');
|
||||
@@ -278,7 +278,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
})
|
||||
);
|
||||
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
|
||||
await typeIn('.key-value label:nth-child(1) input', 'superSecret');
|
||||
assert.dom('.key-value-error').doesNotExist();
|
||||
@@ -297,7 +297,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
})
|
||||
);
|
||||
|
||||
await render(hbs`<SecureVariableForm @model={{this.mockedModel}} />`);
|
||||
await render(hbs`<VariableForm @model={{this.mockedModel}} />`);
|
||||
|
||||
await click('.key-value button.add-more');
|
||||
|
||||
@@ -332,7 +332,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
this.set('view', 'table');
|
||||
|
||||
await render(
|
||||
hbs`<SecureVariableForm @model={{this.mockedModel}} @existingVariables={{this.existingVariables}} @view={{this.view}} />`
|
||||
hbs`<VariableForm @model={{this.mockedModel}} @existingVariables={{this.existingVariables}} @view={{this.view}} />`
|
||||
);
|
||||
assert.dom('.key-value').exists();
|
||||
assert.dom('.CodeMirror').doesNotExist();
|
||||
@@ -359,7 +359,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
this.set('view', 'json');
|
||||
|
||||
await render(
|
||||
hbs`<SecureVariableForm @model={{this.mockedModel}} @view={{this.view}} />`
|
||||
hbs`<VariableForm @model={{this.mockedModel}} @view={{this.view}} />`
|
||||
);
|
||||
|
||||
await percySnapshot(assert);
|
||||
@@ -406,7 +406,7 @@ module('Integration | Component | secure-variable-form', function (hooks) {
|
||||
this.set('view', 'json');
|
||||
|
||||
await render(
|
||||
hbs`<SecureVariableForm @model={{this.mockedModel}} @view={{this.view}} />`
|
||||
hbs`<VariableForm @model={{this.mockedModel}} @view={{this.view}} />`
|
||||
);
|
||||
|
||||
codeFillable('[data-test-json-editor]').get()(
|
||||
@@ -89,7 +89,7 @@ module('Integration | Component | variable-paths', function (hooks) {
|
||||
{
|
||||
Name: '*',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list', 'read'],
|
||||
|
||||
@@ -44,7 +44,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'default',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -88,7 +88,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: '*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -128,7 +128,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'madness',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['read', 'list', 'write'],
|
||||
@@ -174,7 +174,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'default',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -218,7 +218,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: '*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -258,7 +258,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'pablo',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['read', 'list', 'write'],
|
||||
@@ -304,7 +304,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'default',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -348,7 +348,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: '*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -388,7 +388,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'pablo/*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['read', 'list', 'write'],
|
||||
@@ -437,7 +437,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'default',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -481,7 +481,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: '*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -521,7 +521,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: '*/rilkes',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['read', 'list', 'write'],
|
||||
@@ -570,7 +570,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'default',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['write', 'read', 'destroy', 'list'],
|
||||
@@ -614,7 +614,7 @@ module('Unit | Ability | abstract', function (hooks) {
|
||||
],
|
||||
Name: 'pablo/*',
|
||||
Policy: 'write',
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['read', 'list', 'write'],
|
||||
|
||||
@@ -48,7 +48,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.ok(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it permits listing variables when token has SecureVariables with list capabilities in its rules', function (assert) {
|
||||
test('it permits listing variables when token has Variables with list capabilities in its rules', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -59,7 +59,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['list'], PathSpec: '*' }],
|
||||
},
|
||||
},
|
||||
@@ -74,7 +74,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.ok(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it does not permit listing variables when token has SecureVariables alone in its rules', function (assert) {
|
||||
test('it does not permit listing variables when token has Variables alone in its rules', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -85,7 +85,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {},
|
||||
Variables: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -98,7 +98,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.notOk(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it does not permit listing variables when token has a null SecureVariables block', function (assert) {
|
||||
test('it does not permit listing variables when token has a null Variables block', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -109,7 +109,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: null,
|
||||
Variables: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -122,7 +122,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.notOk(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it does not permit listing variables when token has a SecureVariables block where paths are without capabilities', function (assert) {
|
||||
test('it does not permit listing variables when token has a Variables block where paths are without capabilities', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -133,7 +133,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: [], PathSpec: '*' },
|
||||
{ Capabilities: [], PathSpec: 'foo' },
|
||||
@@ -152,7 +152,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.notOk(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it does not permit listing variables when token has no SecureVariables block', function (assert) {
|
||||
test('it does not permit listing variables when token has no Variables block', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -175,7 +175,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.notOk(this.ability.canList);
|
||||
});
|
||||
|
||||
test('it permits listing variables when token multiple namespaces, only one of which having a SecureVariables block', function (assert) {
|
||||
test('it permits listing variables when token multiple namespaces, only one of which having a Variables block', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -186,19 +186,19 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: null,
|
||||
Variables: null,
|
||||
},
|
||||
{
|
||||
Name: 'nonsense',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: [], PathSpec: '*' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'shenanigans',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['list'], PathSpec: 'foo/bar/baz' },
|
||||
],
|
||||
@@ -249,7 +249,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.ok(this.ability.canWrite);
|
||||
});
|
||||
|
||||
test('it permits creating variables when token has SecureVariables with write capabilities in its rules', function (assert) {
|
||||
test('it permits creating variables when token has Variables with write capabilities in its rules', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -260,7 +260,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: '*' }],
|
||||
},
|
||||
},
|
||||
@@ -286,14 +286,14 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['list'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'pablo',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
@@ -344,7 +344,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.ok(this.ability.canDestroy);
|
||||
});
|
||||
|
||||
test('it permits destroying variables when token has SecureVariables with write capabilities in its rules', function (assert) {
|
||||
test('it permits destroying variables when token has Variables with write capabilities in its rules', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -355,7 +355,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['destroy'], PathSpec: '*' }],
|
||||
},
|
||||
},
|
||||
@@ -381,14 +381,14 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['list'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'pablo',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['destroy'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
@@ -439,7 +439,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
assert.ok(this.ability.canRead);
|
||||
});
|
||||
|
||||
test('it permits reading variables when token has SecureVariables with read capabilities in its rules', function (assert) {
|
||||
test('it permits reading variables when token has Variables with read capabilities in its rules', function (assert) {
|
||||
const mockToken = Service.extend({
|
||||
aclEnabled: true,
|
||||
selfToken: { type: 'client' },
|
||||
@@ -450,7 +450,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['read'], PathSpec: '*' }],
|
||||
},
|
||||
},
|
||||
@@ -476,14 +476,14 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['list'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'pablo',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['read'], PathSpec: 'foo/bar' }],
|
||||
},
|
||||
},
|
||||
@@ -513,7 +513,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: 'foo' }],
|
||||
},
|
||||
},
|
||||
@@ -546,7 +546,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['write'], PathSpec: 'foo/*' },
|
||||
{ Capabilities: ['write'], PathSpec: 'foo/bar/*' },
|
||||
@@ -582,7 +582,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: 'foo/*' }],
|
||||
},
|
||||
},
|
||||
@@ -615,7 +615,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['write'], PathSpec: '*/bar' },
|
||||
{ Capabilities: ['write'], PathSpec: '*/bar/baz' },
|
||||
@@ -651,7 +651,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['write'], PathSpec: '*/bar' },
|
||||
{ Capabilities: ['write'], PathSpec: 'foo/*' },
|
||||
@@ -687,7 +687,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
'Path "*"': {
|
||||
Capabilities: ['write'],
|
||||
},
|
||||
@@ -1082,14 +1082,14 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: 'foo' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'bar',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['read', 'write'], PathSpec: 'foo' },
|
||||
],
|
||||
@@ -1129,14 +1129,14 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'default',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [{ Capabilities: ['write'], PathSpec: 'foo' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: 'bar',
|
||||
Capabilities: [],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{ Capabilities: ['read', 'write'], PathSpec: 'foo' },
|
||||
],
|
||||
@@ -1176,7 +1176,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: '*',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list'],
|
||||
@@ -1188,7 +1188,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'namespace-1',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list', 'read', 'destroy', 'create'],
|
||||
@@ -1200,7 +1200,7 @@ module('Unit | Ability | variable', function (hooks) {
|
||||
{
|
||||
Name: 'namespace-2',
|
||||
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
||||
SecureVariables: {
|
||||
Variables: {
|
||||
Paths: [
|
||||
{
|
||||
Capabilities: ['list', 'read', 'destroy', 'create'],
|
||||
|
||||
@@ -61,17 +61,17 @@ module('Unit | Utility | path-tree', function () {
|
||||
assert.equal(
|
||||
Object.keys(tree.findPath('a/b').files).length,
|
||||
4,
|
||||
'Multiple files are listed at a found non-terminal compacted path with many secure variables'
|
||||
'Multiple files are listed at a found non-terminal compacted path with many variables'
|
||||
);
|
||||
assert.equal(
|
||||
Object.keys(tree.findPath('a/b/c/doberman').files).length,
|
||||
1,
|
||||
'One file listed at a found compacted path with a single secure variable'
|
||||
'One file listed at a found compacted path with a single variable'
|
||||
);
|
||||
assert.equal(
|
||||
Object.keys(tree.findPath('a/b/c/dachshund').files).length,
|
||||
2,
|
||||
'Multiple files listed at a found terminal compacted path with many secure variables'
|
||||
'Multiple files listed at a found terminal compacted path with many variables'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user