From 88b820f0ca3d4c219800f1d5ee334a48693ba162 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Mon, 29 Aug 2022 14:31:16 -0400 Subject: [PATCH 1/4] ability rename --- ui/app/abilities/variable.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ui/app/abilities/variable.js b/ui/app/abilities/variable.js index 6d392edb9..4f8e86351 100644 --- a/ui/app/abilities/variable.js +++ b/ui/app/abilities/variable.js @@ -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, From 9b415c96b43cfd14aa399a0b412284bf404749b7 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Mon, 29 Aug 2022 14:35:43 -0400 Subject: [PATCH 2/4] Variable form and css classes --- ...re-variable-form.hbs => variable-form.hbs} | 16 ++++++------ ...cure-variable-form.js => variable-form.js} | 2 +- .../input-group.hbs | 0 .../input-group.js | 0 .../namespace-filter.hbs | 0 .../namespace-filter.js | 0 .../related-entities.hbs | 0 ui/app/styles/components.scss | 2 +- .../{secure-variables.scss => variables.scss} | 2 +- ui/app/templates/variables/new.hbs | 6 ++--- ui/app/templates/variables/variable/edit.hbs | 4 +-- ui/app/templates/variables/variable/index.hbs | 2 +- ...ble-form-test.js => variable-form-test.js} | 26 +++++++++---------- 13 files changed, 30 insertions(+), 30 deletions(-) rename ui/app/components/{secure-variable-form.hbs => variable-form.hbs} (90%) rename ui/app/components/{secure-variable-form.js => variable-form.js} (99%) rename ui/app/components/{secure-variable-form => variable-form}/input-group.hbs (100%) rename ui/app/components/{secure-variable-form => variable-form}/input-group.js (100%) rename ui/app/components/{secure-variable-form => variable-form}/namespace-filter.hbs (100%) rename ui/app/components/{secure-variable-form => variable-form}/namespace-filter.js (100%) rename ui/app/components/{secure-variable-form => variable-form}/related-entities.hbs (100%) rename ui/app/styles/components/{secure-variables.scss => variables.scss} (99%) rename ui/tests/integration/components/{secure-variable-form-test.js => variable-form-test.js} (91%) diff --git a/ui/app/components/secure-variable-form.hbs b/ui/app/components/variable-form.hbs similarity index 90% rename from ui/app/components/secure-variable-form.hbs rename to ui/app/components/variable-form.hbs index e50e9fe73..6bb2e1127 100644 --- a/ui/app/components/secure-variable-form.hbs +++ b/ui/app/components/variable-form.hbs @@ -1,17 +1,17 @@ {{did-update this.onViewChange @view}} {{did-insert this.establishKeyValues}} -
+ {{#if @model.isNew}} {{/if}} {{#if this.hasConflict}}
-

Heads up! Your Secure Variable has a conflict.

+

Heads up! Your variable has a conflict.

This might be because someone else tried saving in the time since you've had it open.

{{#if this.conflictingVariable.modifyTime}} @@ -46,7 +46,7 @@ /> {{#if this.duplicatePathWarning}}

- There is already a Secure Variable located at + There is already a variable located at {{this.path}} .
@@ -55,13 +55,13 @@ @route="variables.variable.edit" @model={{this.duplicatePathWarning.path}} > - edit the existing Secure Variable + edit the existing variable .

{{/if}} - - + {{#if (eq entry this.keyValues.lastObject)}} {{/if}} @@ -46,11 +46,11 @@
{{#if (eq this.namespaceSelection "*")}}

- No Secure Variables + No Variables

{{#if (can "write variable" path="*" namespace=this.namespaceSelection)}}

- Get started by creating a new secure variable + Get started by creating a new variable

{{/if}} {{else}} diff --git a/ui/app/templates/variables/path.hbs b/ui/app/templates/variables/path.hbs index f4838b423..a6bb424f0 100644 --- a/ui/app/templates/variables/path.hbs +++ b/ui/app/templates/variables/path.hbs @@ -1,4 +1,4 @@ -{{page-title "Secure Variables: " this.absolutePath}} +{{page-title "Variables: " this.absolutePath}} {{#each this.breadcrumbs as |crumb|}} {{/each}} @@ -21,7 +21,7 @@ @query={{hash path=(concat this.absolutePath "/")}} class="button is-primary" > - Create Secure Variable + Create Variable {{else}} {{/if}}
@@ -50,7 +50,7 @@ Path /{{this.absolutePath}} contains no variables

- To get started, create a new secure variable here, or go back to the Secure Variables root directory. + To get started, create a new variable here, or go back to the Variables root directory.

{{else}}

diff --git a/ui/app/templates/variables/variable.hbs b/ui/app/templates/variables/variable.hbs index 7eea2143a..88ba26409 100644 --- a/ui/app/templates/variables/variable.hbs +++ b/ui/app/templates/variables/variable.hbs @@ -1,4 +1,4 @@ -{{page-title "Secure Variables: " this.model.path}} +{{page-title "Variables: " this.model.path}} {{#each this.breadcrumbs as |crumb|}} {{/each}} diff --git a/ui/app/utils/path-tree.js b/ui/app/utils/path-tree.js index ea9db0a36..fc907289f 100644 --- a/ui/app/utils/path-tree.js +++ b/ui/app/utils/path-tree.js @@ -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 */ /** diff --git a/ui/mirage/config.js b/ui/mirage/config.js index f285708fe..c73582084 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -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) { diff --git a/ui/mirage/factories/token.js b/ui/mirage/factories/token.js index 59a3fa393..575463c9b 100644 --- a/ui/mirage/factories/token.js +++ b/ui/mirage/factories/token.js @@ -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"] } @@ -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"] } diff --git a/ui/tests/acceptance/secure-variables-test.js b/ui/tests/acceptance/variables-test.js similarity index 100% rename from ui/tests/acceptance/secure-variables-test.js rename to ui/tests/acceptance/variables-test.js diff --git a/ui/tests/unit/utils/path-tree-test.js b/ui/tests/unit/utils/path-tree-test.js index 1a51bf469..3060ae6b4 100644 --- a/ui/tests/unit/utils/path-tree-test.js +++ b/ui/tests/unit/utils/path-tree-test.js @@ -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' ); }); });