From a095225ba7c90fecb6cc51c833c05cd7ec6d8de8 Mon Sep 17 00:00:00 2001 From: Jai <41024828+ChaiWithJai@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:33:47 -0400 Subject: [PATCH] add namespace to path matching algorithm (#13948) * refact: namespace should be bound property * chore: pass bound namespace property in template * chore: update tests to account for bound namespace refactoring * test: add test coverage for factoring namespace in path matching algo --- ui/app/abilities/variable.js | 7 +- ui/app/templates/variables/path.hbs | 2 +- ui/app/templates/variables/variable/index.hbs | 4 +- ui/tests/acceptance/secure-variables-test.js | 7 ++ ui/tests/unit/abilities/variable-test.js | 96 +++++++++++++++++++ 5 files changed, 108 insertions(+), 8 deletions(-) diff --git a/ui/app/abilities/variable.js b/ui/app/abilities/variable.js index 7b22d5d40..caa0ae5ec 100644 --- a/ui/app/abilities/variable.js +++ b/ui/app/abilities/variable.js @@ -61,15 +61,12 @@ export default class Variable extends AbstractAbility { ?.capabilities?.includes('destroy'); } - @computed('token.selfTokenPolicies.[]', '_namespace') + @computed('token.selfTokenPolicies.[]', 'namespace') get allPaths() { return (get(this, 'token.selfTokenPolicies') || []) .toArray() .reduce((paths, policy) => { - const matchingNamespace = this._findMatchingNamespace( - get(policy, 'rulesJSON.Namespaces') || [], - this._namespace - ); + const matchingNamespace = this.namespace ?? 'default'; const variables = (get(policy, 'rulesJSON.Namespaces') || []).find( (namespace) => namespace.Name === matchingNamespace diff --git a/ui/app/templates/variables/path.hbs b/ui/app/templates/variables/path.hbs index 4d02ee84c..1a890ba1f 100644 --- a/ui/app/templates/variables/path.hbs +++ b/ui/app/templates/variables/path.hbs @@ -15,7 +15,7 @@ /> {{/if}}