diff --git a/ui/app/components/mount-backend-form.js b/ui/app/components/mount-backend-form.js index 6427bd509..fbfb6c6a0 100644 --- a/ui/app/components/mount-backend-form.js +++ b/ui/app/components/mount-backend-form.js @@ -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; diff --git a/ui/app/controllers/vault/cluster/secrets/backends.js b/ui/app/controllers/vault/cluster/secrets/backends.js index 98cea196f..97345c62f 100644 --- a/ui/app/controllers/vault/cluster/secrets/backends.js +++ b/ui/app/controllers/vault/cluster/secrets/backends.js @@ -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(), }); diff --git a/ui/app/templates/vault/cluster/access/methods.hbs b/ui/app/templates/vault/cluster/access/methods.hbs index b073ef852..624bebd78 100644 --- a/ui/app/templates/vault/cluster/access/methods.hbs +++ b/ui/app/templates/vault/cluster/access/methods.hbs @@ -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" diff --git a/ui/app/templates/vault/cluster/secrets/backends.hbs b/ui/app/templates/vault/cluster/secrets/backends.hbs index 9dc7ae1e4..7dd95621e 100644 --- a/ui/app/templates/vault/cluster/secrets/backends.hbs +++ b/ui/app/templates/vault/cluster/secrets/backends.hbs @@ -59,6 +59,23 @@ View Configuration {{/link-to}} + {{#unless (eq backend.type "cubbyhole")}} +
  • + + Disable + +
  • + {{/unless}} {{#if item.updatePath.isPending}}
  • @@ -105,6 +122,22 @@ View Configuration {{/link-to}}
  • +
  • + + Disable + +
  • {{/popup-menu}} diff --git a/ui/tests/acceptance/secrets/backend/engines-test.js b/ui/tests/acceptance/secrets/backend/engines-test.js new file mode 100644 index 000000000..f06091a56 --- /dev/null +++ b/ui/tests/acceptance/secrets/backend/engines-test.js @@ -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' + ); + }); +}); diff --git a/ui/tests/acceptance/settings/auth/enable-test.js b/ui/tests/acceptance/settings/auth/enable-test.js index bba0c6f37..3e24f010b 100644 --- a/ui/tests/acceptance/settings/auth/enable-test.js +++ b/ui/tests/acceptance/settings/auth/enable-test.js @@ -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' ); }); diff --git a/ui/tests/pages/secrets/backends.js b/ui/tests/pages/secrets/backends.js index 776cc301d..555a4455a 100644 --- a/ui/tests/pages/secrets/backends.js +++ b/ui/tests/pages/secrets/backends.js @@ -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', + }), });