mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02:00
* created new JsonTemplate component * used JsonTemplate in modal PolicyTemplate to replace code there * renamed component and fixed when the editor content shows up * changed PolicyForm to render example modal only conditionally. added desription to policy-example.js * fixed bug in policy-example.js & edited description of that file, removed functionality from policy-template.js (it is already in policy-example.js) * changed margin on text to better match Figma design, added example modal for when editing a policy * added tests for PolicyExample in policy-example-tests * added PolicyForm tests for (1) cancelling the creation/edit of policy and (2) properly rendering the policy example modal * add changelog * clean up code by removing unnecessary comments * changed a conditional in policy-form.hbs for better readability (Kianna's comment) * fixed description in policy-example.js, changed wording for RGP example, changed wording in policy-form-test.js * added 2 more asserts in policy-form-test.js. Changed some naming for selectors in the test file * added EGP policy to PolicyExample component, moved some functionality from .hbs to .js file and vise versa * added tests to policy-exammple-test.js and policy-form-test.js to account for new EGP policy * simplified all PolicyExample tests in policy-exmaple-test.js * removed beforeEach hook in policy-exmaple-test.js
89 lines
2.8 KiB
JavaScript
89 lines
2.8 KiB
JavaScript
/**
|
||
* Copyright (c) HashiCorp, Inc.
|
||
* SPDX-License-Identifier: MPL-2.0
|
||
*/
|
||
|
||
import { module, test } from 'qunit';
|
||
import { setupRenderingTest } from 'vault/tests/helpers';
|
||
import { render } from '@ember/test-helpers';
|
||
import { hbs } from 'ember-cli-htmlbars';
|
||
|
||
const SELECTORS = {
|
||
policyText: '[data-test-modal-title]',
|
||
policyDescription: (type) => `[data-test-example-modal-text=${type}]`,
|
||
jsonText: '[data-test-example-modal-json-text]',
|
||
informationLink: '[data-test-example-modal-information-link]',
|
||
};
|
||
|
||
module('Integration | Component | policy-example', function (hooks) {
|
||
setupRenderingTest(hooks);
|
||
|
||
test('it renders the correct paragraph for ACL policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="acl"
|
||
/>
|
||
`);
|
||
assert
|
||
.dom(SELECTORS.policyDescription('acl'))
|
||
.hasText(
|
||
'ACL Policies are written in Hashicorp Configuration Language ( HCL ) or JSON and describe which paths in Vault a user or machine is allowed to access. Here is an example policy:'
|
||
);
|
||
});
|
||
|
||
test('it renders the correct paragraph for RGP policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="rgp"
|
||
/>
|
||
`);
|
||
assert
|
||
.dom(SELECTORS.policyDescription('rgp'))
|
||
.hasText(
|
||
'Role Governing Policies (RGPs) are tied to client tokens or identities which is similar to ACL policies . They use Sentinel as a language framework to enable fine-grained policy decisions.'
|
||
);
|
||
});
|
||
|
||
test('it renders the correct paragraph for EGP policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="egp"
|
||
/>
|
||
`);
|
||
assert
|
||
.dom(SELECTORS.policyDescription('egp'))
|
||
.hasText(
|
||
`Endpoint Governing Policies (EGPs) are tied to particular paths (e.g. aws/creds/ ) instead of tokens. They use Sentinel as a language to access properties of the incoming requests.`
|
||
);
|
||
});
|
||
|
||
test('it renders the correct JSON editor text for ACL policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="acl"
|
||
/>
|
||
`);
|
||
assert.dom(SELECTORS.jsonText).includesText(`# Grant 'create', 'read' , 'update', and ‘list’ permission`);
|
||
});
|
||
|
||
test('it renders the correct JSON editor text for RGP policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="rgp"
|
||
/>
|
||
`);
|
||
assert
|
||
.dom(SELECTORS.jsonText)
|
||
.includesText(`# Import strings library that exposes common string operations`);
|
||
});
|
||
|
||
test('it renders the correct JSON editor text for EGP policy', async function (assert) {
|
||
await render(hbs`
|
||
<PolicyExample
|
||
@policyType="egp"
|
||
/>
|
||
`);
|
||
assert.dom(SELECTORS.jsonText).includesText(`# Expect requests to only happen during work days (Monday `);
|
||
});
|
||
});
|