diff --git a/changelog/19290.txt b/changelog/19290.txt new file mode 100644 index 000000000000..1a4511590c69 --- /dev/null +++ b/changelog/19290.txt @@ -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. +``` diff --git a/ui/app/components/auth-config-form/options.js b/ui/app/components/auth-config-form/options.js index a50bf96bee76..b5d5fed67d29 100644 --- a/ui/app/components/auth-config-form/options.js +++ b/ui/app/components/auth-config-form/options.js @@ -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; } diff --git a/ui/app/models/mount-config.js b/ui/app/models/mount-config.js index edc624c2fae4..b2de642e946e 100644 --- a/ui/app/models/mount-config.js +++ b/ui/app/models/mount-config.js @@ -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; } diff --git a/ui/tests/acceptance/settings/auth/configure/section-test.js b/ui/tests/acceptance/settings/auth/configure/section-test.js index b9b1bfba1c61..0807bc8c0755 100644 --- a/ui/tests/acceptance/settings/auth/configure/section-test.js +++ b/ui/tests/acceptance/settings/auth/configure/section-test.js @@ -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'; @@ -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, @@ -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']) { diff --git a/ui/tests/integration/components/mount-backend-form-test.js b/ui/tests/integration/components/mount-backend-form-test.js index 53ac56daca2a..5fdc7357401b 100644 --- a/ui/tests/integration/components/mount-backend-form-test.js +++ b/ui/tests/integration/components/mount-backend-form-test.js @@ -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`` + ); + 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);