[Bugfix][UI]: Fix auth method disable bug (#9773) (#9790)

* Fix auth method disable bug

* Add acceptance tests

* Use api parseError helper

Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com>
This commit is contained in:
Vault Automation 2025-10-02 13:14:09 -04:00 committed by GitHub
parent 732c1e590d
commit 109ff8d77d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 5 deletions

View File

@ -12,6 +12,8 @@ import sortObjects from 'vault/utils/sort-objects';
export default class VaultClusterAccessMethodsController extends Controller {
@service flashMessages;
@service api;
@service router;
@tracked authMethodOptions = [];
@tracked selectedAuthType = null;
@ -78,12 +80,12 @@ export default class VaultClusterAccessMethodsController extends Controller {
*disableMethod(method) {
const { type, path } = method;
try {
yield method.destroyRecord();
yield this.api.sys.authDisableMethod(path);
this.flashMessages.success(`The ${type} Auth Method at ${path} has been disabled.`);
this.router.transitionTo('vault.cluster.access.methods');
} catch (err) {
this.flashMessages.danger(
`There was an error disabling Auth Method at ${path}: ${err.errors.join(' ')}.`
);
const { message } = yield this.api.parseError(err);
this.flashMessages.danger(`There was an error disabling Auth Method at ${path}: ${message}.`);
} finally {
this.methodToDisable = null;
}

View File

@ -102,7 +102,11 @@
(has-capability this.model.capabilities "delete" pathKey="authMethodDelete" params=method.id)
)
}}
<dd.Interactive @color="critical" {{on "click" (fn (mut this.methodToDisable) method)}}>
<dd.Interactive
@color="critical"
{{on "click" (fn (mut this.methodToDisable) method)}}
data-test-button="Disable auth method"
>
Disable
</dd.Interactive>
{{/if}}

View File

@ -91,4 +91,17 @@ module('Acceptance | auth-methods list view', function (hooks) {
.exists({ count: 1 }, `auth method ${key} appears in list view after navigating from OIDC Provider`);
}
});
test('it should disable an auth method', async function (assert) {
const authPath1 = `userpass-1-${this.uid}`;
const type = 'userpass';
await visit('/vault/settings/auth/enable');
await runCmd(mountAuthCmd(type, authPath1));
await visit('/vault/access/');
await click(`${GENERAL.linkedBlock(authPath1)} ${GENERAL.menuTrigger}`);
await click(GENERAL.button('Disable auth method'));
await click(GENERAL.confirmButton);
assert.dom(GENERAL.linkedBlock(authPath1)).doesNotExist('auth mount disabled');
await runCmd(`delete sys/auth/${authPath1}`);
});
});