23946d75a7
* upgrade yargs-parser for better quote handling * remove encoding pre&post parse, and remove wrapping quotes when pushing to data array * add test for spaces and strings * base64 encode policy strings in tests where we're using them with string interpolation * improve regex to only remove wrapping single and double quotes * don't support quotes in paths in the web cli
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
import { create } from 'ember-cli-page-object';
|
|
import { module, test } from 'qunit';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import authPage from 'vault/tests/pages/auth';
|
|
import logout from 'vault/tests/pages/logout';
|
|
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
|
|
|
|
const consoleComponent = create(consoleClass);
|
|
|
|
const tokenWithPolicy = async function(name, policy) {
|
|
await consoleComponent.runCommands([
|
|
`write sys/policies/acl/${name} policy=${btoa(policy)}`,
|
|
`write -field=client_token auth/token/create policies=${name}`,
|
|
]);
|
|
|
|
return consoleComponent.lastLogOutput;
|
|
};
|
|
|
|
module('Acceptance | cluster', function(hooks) {
|
|
setupApplicationTest(hooks);
|
|
|
|
hooks.beforeEach(async function() {
|
|
await logout.visit();
|
|
return authPage.login();
|
|
});
|
|
|
|
test('hides nav item if user does not have permission', async function(assert) {
|
|
const deny_policies_policy = `
|
|
path "sys/policies/*" {
|
|
capabilities = ["deny"]
|
|
},
|
|
`;
|
|
|
|
const userToken = await tokenWithPolicy('hide-policies-nav', deny_policies_policy);
|
|
await logout.visit();
|
|
await authPage.login(userToken);
|
|
|
|
assert.dom('[data-test-navbar-item=policies]').doesNotExist();
|
|
await logout.visit();
|
|
});
|
|
|
|
test('enterprise nav item links to first route that user has access to', async function(assert) {
|
|
const read_rgp_policy = `
|
|
path "sys/policies/rgp" {
|
|
capabilities = ["read"]
|
|
},
|
|
`;
|
|
|
|
const userToken = await tokenWithPolicy('show-policies-nav', read_rgp_policy);
|
|
await logout.visit();
|
|
await authPage.login(userToken);
|
|
|
|
assert.dom('[data-test-navbar-item=policies]').hasAttribute('href', '/ui/vault/policies/rgp');
|
|
await logout.visit();
|
|
});
|
|
});
|