mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-09 04:41:10 +01:00
* 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:
parent
732c1e590d
commit
109ff8d77d
@ -12,6 +12,8 @@ import sortObjects from 'vault/utils/sort-objects';
|
|||||||
|
|
||||||
export default class VaultClusterAccessMethodsController extends Controller {
|
export default class VaultClusterAccessMethodsController extends Controller {
|
||||||
@service flashMessages;
|
@service flashMessages;
|
||||||
|
@service api;
|
||||||
|
@service router;
|
||||||
|
|
||||||
@tracked authMethodOptions = [];
|
@tracked authMethodOptions = [];
|
||||||
@tracked selectedAuthType = null;
|
@tracked selectedAuthType = null;
|
||||||
@ -78,12 +80,12 @@ export default class VaultClusterAccessMethodsController extends Controller {
|
|||||||
*disableMethod(method) {
|
*disableMethod(method) {
|
||||||
const { type, path } = method;
|
const { type, path } = method;
|
||||||
try {
|
try {
|
||||||
yield method.destroyRecord();
|
yield this.api.sys.authDisableMethod(path);
|
||||||
this.flashMessages.success(`The ${type} Auth Method at ${path} has been disabled.`);
|
this.flashMessages.success(`The ${type} Auth Method at ${path} has been disabled.`);
|
||||||
|
this.router.transitionTo('vault.cluster.access.methods');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.flashMessages.danger(
|
const { message } = yield this.api.parseError(err);
|
||||||
`There was an error disabling Auth Method at ${path}: ${err.errors.join(' ')}.`
|
this.flashMessages.danger(`There was an error disabling Auth Method at ${path}: ${message}.`);
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
this.methodToDisable = null;
|
this.methodToDisable = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,11 @@
|
|||||||
(has-capability this.model.capabilities "delete" pathKey="authMethodDelete" params=method.id)
|
(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
|
Disable
|
||||||
</dd.Interactive>
|
</dd.Interactive>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@ -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`);
|
.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}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user