Skip to content

Commit 109ff8d

Browse files
[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 <[email protected]>
1 parent 732c1e5 commit 109ff8d

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

ui/app/controllers/vault/cluster/access/methods.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import sortObjects from 'vault/utils/sort-objects';
1212

1313
export default class VaultClusterAccessMethodsController extends Controller {
1414
@service flashMessages;
15+
@service api;
16+
@service router;
1517

1618
@tracked authMethodOptions = [];
1719
@tracked selectedAuthType = null;
@@ -78,12 +80,12 @@ export default class VaultClusterAccessMethodsController extends Controller {
7880
*disableMethod(method) {
7981
const { type, path } = method;
8082
try {
81-
yield method.destroyRecord();
83+
yield this.api.sys.authDisableMethod(path);
8284
this.flashMessages.success(`The ${type} Auth Method at ${path} has been disabled.`);
85+
this.router.transitionTo('vault.cluster.access.methods');
8386
} catch (err) {
84-
this.flashMessages.danger(
85-
`There was an error disabling Auth Method at ${path}: ${err.errors.join(' ')}.`
86-
);
87+
const { message } = yield this.api.parseError(err);
88+
this.flashMessages.danger(`There was an error disabling Auth Method at ${path}: ${message}.`);
8789
} finally {
8890
this.methodToDisable = null;
8991
}

ui/app/templates/vault/cluster/access/methods.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@
102102
(has-capability this.model.capabilities "delete" pathKey="authMethodDelete" params=method.id)
103103
)
104104
}}
105-
<dd.Interactive @color="critical" {{on "click" (fn (mut this.methodToDisable) method)}}>
105+
<dd.Interactive
106+
@color="critical"
107+
{{on "click" (fn (mut this.methodToDisable) method)}}
108+
data-test-button="Disable auth method"
109+
>
106110
Disable
107111
</dd.Interactive>
108112
{{/if}}

ui/tests/acceptance/access/methods-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,17 @@ module('Acceptance | auth-methods list view', function (hooks) {
9191
.exists({ count: 1 }, `auth method ${key} appears in list view after navigating from OIDC Provider`);
9292
}
9393
});
94+
95+
test('it should disable an auth method', async function (assert) {
96+
const authPath1 = `userpass-1-${this.uid}`;
97+
const type = 'userpass';
98+
await visit('/vault/settings/auth/enable');
99+
await runCmd(mountAuthCmd(type, authPath1));
100+
await visit('/vault/access/');
101+
await click(`${GENERAL.linkedBlock(authPath1)} ${GENERAL.menuTrigger}`);
102+
await click(GENERAL.button('Disable auth method'));
103+
await click(GENERAL.confirmButton);
104+
assert.dom(GENERAL.linkedBlock(authPath1)).doesNotExist('auth mount disabled');
105+
await runCmd(`delete sys/auth/${authPath1}`);
106+
});
94107
});

0 commit comments

Comments
 (0)