Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Auth method token_type possibleValues fix into release/1.13.x #19322

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/19290.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Remove `default` and add `default-service` and `default-batch` to UI token_type for auth mount and tuning.
```
2 changes: 1 addition & 1 deletion ui/app/components/auth-config-form/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default AuthConfigComponent.extend({
const data = this.model.config.serialize();
data.description = this.model.description;

// token_type should not be tuneable for the token auth method, default is 'default-service'
// token_type should not be tuneable for the token auth method.
if (this.model.type === 'token') {
delete data.token_type;
}
Expand Down
6 changes: 3 additions & 3 deletions ui/app/models/mount-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export default class MountConfigModel extends Model {
@attr('string', {
label: 'Token Type',
helpText:
"The type of token that should be generated via this role. Can be `service`, `batch`, or `default` to use the mount's default (which unless changed will be `service` tokens).",
possibleValues: ['default', 'batch', 'service'],
defaultFormValue: 'default',
'The type of token that should be generated via this role. For `default-service` and `default-batch` service and batch tokens will be issued respectively, unless the auth method explicitly requests a different type.',
possibleValues: ['default-service', 'default-batch', 'batch', 'service'],
noDefault: true,
})
tokenType;
}
8 changes: 8 additions & 0 deletions ui/tests/acceptance/settings/auth/configure/section-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { create } from 'ember-cli-page-object';
import { fillIn } from '@ember/test-helpers';
import enablePage from 'vault/tests/pages/settings/auth/enable';
import page from 'vault/tests/pages/settings/auth/configure/section';
import indexPage from 'vault/tests/pages/settings/auth/configure/index';
Expand Down Expand Up @@ -29,6 +30,10 @@ module('Acceptance | settings/auth/configure/section', function (hooks) {
await enablePage.enable(type, path);
await page.visit({ path, section });
await page.fillInTextarea('description', 'This is AppRole!');
assert
.dom('[data-test-input="config.tokenType"]')
.hasValue('default-service', 'as default the token type selected is default-service.');
await fillIn('[data-test-input="config.tokenType"]', 'batch');
await page.save();
assert.strictEqual(
page.flash.latestMessage,
Expand All @@ -40,8 +45,11 @@ module('Acceptance | settings/auth/configure/section', function (hooks) {
`/v1/sys/mounts/auth/${path}/tune`
)[0];
const keys = Object.keys(JSON.parse(tuneRequest.requestBody));
const token_type = JSON.parse(tuneRequest.requestBody).token_type;
assert.strictEqual(token_type, 'batch', 'passes new token type');
assert.ok(keys.includes('default_lease_ttl'), 'passes default_lease_ttl on tune');
assert.ok(keys.includes('max_lease_ttl'), 'passes max_lease_ttl on tune');
assert.ok(keys.includes('description'), 'passes updated description on tune');
});

for (const type of ['aws', 'azure', 'gcp', 'github', 'kubernetes']) {
Expand Down
17 changes: 17 additions & 0 deletions ui/tests/integration/components/mount-backend-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ module('Integration | Component | mount backend form', function (hooks) {
assert.strictEqual(component.pathValue, 'newpath', 'keeps custom path value');
});

test('it does not show a selected token type when first mounting an auth method', async function (assert) {
await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
);
await component.selectType('github');
await component.next();
await component.toggleOptions();
assert
.dom('[data-test-input="config.tokenType"]')
.hasValue('', 'token type does not have a default value.');
const selectOptions = document.querySelector('[data-test-input="config.tokenType"]').options;
assert.strictEqual(selectOptions[1].text, 'default-service', 'first option is default-service');
assert.strictEqual(selectOptions[2].text, 'default-batch', 'second option is default-batch');
assert.strictEqual(selectOptions[3].text, 'batch', 'third option is batch');
assert.strictEqual(selectOptions[4].text, 'service', 'fourth option is service');
});

test('it calls mount success', async function (assert) {
assert.expect(3);

Expand Down