Custom tooltip for Generated Token Policies form field on auth methods (#15046)

* the conditional fix

* add test coverage

* changelog

* add possesive

* fix language

* fix

* fix

* change quotes

* fix

* replace with find
This commit is contained in:
Angel Garbarino 2022-04-14 14:58:26 -06:00 committed by GitHub
parent b9acac050a
commit 774bf2241a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 1 deletions

4
changelog/15046.txt Normal file
View File

@ -0,0 +1,4 @@
```release-note:bug
ui: Fix Generated Token's Policies helpText to clarify that comma separated values are not accepted in this field.
```

View File

@ -48,6 +48,16 @@ export default Component.extend({
),
init() {
this._super(...arguments);
this.model.fieldGroups.forEach((element) => {
// overwriting the helpText for Token Polices.
// HelpText from the backend says add a comma separated list, which works on the CLI but not here on the UI.
// This effects TLS Certificates, Userpass, and Kubernetes. https://github.com/hashicorp/vault/issues/10346
if (element.Tokens) {
element.Tokens.find((attr) => attr.name === 'tokenPolicies').options.helpText =
'Add policies that will apply to the generated token for this user. One policy per row.';
}
});
if (this.mode === 'edit') {
// For validation to work in edit mode,
// reconstruct the model values from field group

View File

@ -8,7 +8,7 @@
<Icon @name="info" class="auto-width" aria-label="help" />
</d.Trigger>
<d.Content @defaultClass="tool-tip">
<div class="box">
<div class="box" data-test-info-tooltip-content>
{{yield}}
</div>
</d.Content>

View File

@ -5,6 +5,7 @@ import {
fillIn,
settled,
visit,
triggerEvent,
triggerKeyEvent,
find,
waitUntil,
@ -69,6 +70,18 @@ module('Acceptance | auth backend list', function (hooks) {
await triggerKeyEvent('[data-test-input="username"]', 'keyup', 65);
await fillIn('[data-test-textarea]', user2);
await triggerKeyEvent('[data-test-textarea]', 'keyup', 65);
// test for modified helpText on generated token policies
await click('[data-test-toggle-group="Tokens"]');
let policyFormField = document.querySelector('[data-test-input="tokenPolicies"]');
let tooltipTrigger = policyFormField.querySelector('[data-test-tool-tip-trigger]');
await triggerEvent(tooltipTrigger, 'mouseenter');
assert
.dom('[data-test-info-tooltip-content]')
.hasText(
'Add policies that will apply to the generated token for this user. One policy per row.',
'Overwritten tooltip text displays in token form field.'
);
await click('[data-test-save-config="true"]');
//confirming that the user was created. There was a bug where the apiPath was not being updated when toggling between auth routes