add disable secrets engine button
This commit is contained in:
parent
3b8d543189
commit
60f7d70358
|
@ -115,9 +115,10 @@ export default Component.extend({
|
|||
// err will display via model state
|
||||
return;
|
||||
}
|
||||
this.get('flashMessages').success(
|
||||
`Successfully mounted ${type} ${this.get('mountType')} method at ${path}.`
|
||||
);
|
||||
|
||||
let mountType = this.get('mountType');
|
||||
mountType = mountType === 'secret' ? `${mountType}s engine` : `${mountType} method`;
|
||||
this.get('flashMessages').success(`Successfully mounted the ${type} ${mountType} at ${path}.`);
|
||||
if (this.get('mountType') === 'secret') {
|
||||
yield this.get('onMountSuccess')(type, path);
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { filterBy } from '@ember/object/computed';
|
||||
import { computed } from '@ember/object';
|
||||
import Controller from '@ember/controller';
|
||||
import { task } from 'ember-concurrency';
|
||||
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
|
||||
const LINKED_BACKENDS = supportedSecretBackends();
|
||||
|
||||
|
@ -25,4 +26,16 @@ export default Controller.extend({
|
|||
.sortBy('id');
|
||||
}
|
||||
),
|
||||
|
||||
disableEngine: task(function*(engine) {
|
||||
const { engineType, path } = engine;
|
||||
try {
|
||||
yield engine.destroyRecord();
|
||||
this.get('flashMessages').success(`The ${engineType} secrets engine at ${path} has been disabled.`);
|
||||
} catch (err) {
|
||||
this.get('flashMessages').danger(
|
||||
`There was an error disabling the ${engineType} secrets engine at ${path}: ${err.errors.join(' ')}.`
|
||||
);
|
||||
}
|
||||
}).drop(),
|
||||
});
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
confirmButtonClasses="button is-primary"
|
||||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(perform disableMethod method)
|
||||
confirmMessage=(concat "Are you sure you want to disable auth via " method.id "?")
|
||||
confirmMessage=(concat "Are you sure you want to disable the " method.id " auth method at " method.path "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" method.id))
|
||||
class=(if (get this (concat "shouldDelete-" method.id)) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
|
|
|
@ -59,6 +59,23 @@
|
|||
View Configuration
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{#unless (eq backend.type "cubbyhole")}}
|
||||
<li class="action">
|
||||
<ConfirmAction
|
||||
@confirmButtonClasses="button is-primary"
|
||||
@buttonClasses="link is-destroy"
|
||||
@onConfirmAction={{perform disableEngine backend}}
|
||||
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
|
||||
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@confirmButtonText="Disable"
|
||||
data-test-engine-disable>
|
||||
Disable
|
||||
</ConfirmAction>
|
||||
</li>
|
||||
{{/unless}}
|
||||
{{#if item.updatePath.isPending}}
|
||||
<li class="action">
|
||||
<button disabled=true type="button" class="link button is-loading is-transparent"></button>
|
||||
|
@ -105,6 +122,22 @@
|
|||
View Configuration
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
<ConfirmAction
|
||||
@confirmButtonClasses="button is-primary"
|
||||
@buttonClasses="link is-destroy"
|
||||
@onConfirmAction={{perform disableEngine backend}}
|
||||
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
|
||||
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@confirmButtonText="Disable"
|
||||
data-test-engine-disable
|
||||
>
|
||||
Disable
|
||||
</ConfirmAction>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{/popup-menu}}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import { currentRouteName } from '@ember/test-helpers';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
|
||||
import backendsPage from 'vault/tests/pages/secrets/backends';
|
||||
import authPage from 'vault/tests/pages/auth';
|
||||
|
||||
module('Acceptance | engine/disable', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
|
||||
hooks.beforeEach(function() {
|
||||
return authPage.login();
|
||||
});
|
||||
|
||||
test('disable engine', async function(assert) {
|
||||
// first mount an engine so we can disable it.
|
||||
let enginePath = `alicloud-${new Date().getTime()}`;
|
||||
await mountSecrets.enable('alicloud', enginePath);
|
||||
|
||||
assert.ok(backendsPage.rows.filterBy('path', `${enginePath}/`)[0], 'shows the mounted engine');
|
||||
|
||||
await backendsPage.visit();
|
||||
let row = backendsPage.rows.filterBy('path', `${enginePath}/`)[0];
|
||||
await row.menu();
|
||||
await backendsPage.disableButton();
|
||||
await backendsPage.confirmDisable();
|
||||
|
||||
assert.equal(currentRouteName(), 'vault.cluster.secrets.backends', 'redirects to the backends page');
|
||||
|
||||
assert.equal(
|
||||
backendsPage.rows.filterBy('path', `${enginePath}/`).length,
|
||||
0,
|
||||
'does not show the disabled engine'
|
||||
);
|
||||
});
|
||||
});
|
|
@ -22,7 +22,7 @@ module('Acceptance | settings/auth/enable', function(hooks) {
|
|||
await withFlash(page.enable(type, path), () => {
|
||||
assert.equal(
|
||||
page.flash.latestMessage,
|
||||
`Successfully mounted ${type} auth method at ${path}.`,
|
||||
`Successfully mounted the ${type} auth method at ${path}.`,
|
||||
'success flash shows'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -12,4 +12,10 @@ export default create({
|
|||
configLink: clickable('[data-test-engine-config]', {
|
||||
testContainer: '#ember-testing',
|
||||
}),
|
||||
disableButton: clickable('[data-test-confirm-action-trigger]', {
|
||||
testContainer: '#ember-testing',
|
||||
}),
|
||||
confirmDisable: clickable('[data-test-confirm-button]', {
|
||||
testContainer: '#ember-testing',
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue