open-vault/ui/tests/acceptance/leases-test.js
Jordan Reimer be632db682
Ember Upgrade to 4.4 (#17086)
* runs ember-cli-update to 4.4.0

* updates yarn.lock

* updates dependencies causing runtime errors (#17135)

* Inject Store Service When Accessed Implicitly (#17345)

* adds codemod for injecting store service

* adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms

* updates inject-store-service codemod to only look for .extend object expressions and adds recast options

* runs inject-store-service codemod on js files

* replace query-params helper with hash (#17404)

* Updates/removes dependencies throwing errors in Ember 4.4 (#17396)

* updates ember-responsive to latest

* updates ember-composable-helpers to latest and uses includes helper since contains was removed

* updates ember-concurrency to latest

* updates ember-cli-clipboard to latest

* temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo

* adds missing store injection to auth configure route

* fixes issue with string-list component throwing error for accessing prop in same computation

* fixes non-iterable query params issue in mfa methods controller

* refactors field-to-attrs to handle belongsTo rather than fragments

* converts mount-config fragment to belongsTo on auth-method model

* removes ember-api-actions and adds tune method to auth-method adapter

* converts cluster replication attributes from fragment to relationship

* updates ember-data, removes ember-data-fragments and updates yarn to latest

* removes fragments from secret-engine model

* removes fragment from test-form-model

* removes commented out code

* minor change to inject-store-service codemod and runs again on js files

* Remove LinkTo positional params (#17421)

* updates ember-cli-page-object to latest version

* update toolbar-link to support link-to args and not positional params

* adds replace arg to toolbar-link component

* Clean up js lint errors (#17426)

* replaces assert.equal to assert.strictEqual

* update eslint no-console to error and disables invididual intended uses of console

* cleans up hbs lint warnings (#17432)

* Upgrade bug and test fixes (#17500)

* updates inject-service codemod to take arg for service name and runs for flashMessages service

* fixes hbs lint error after merging main

* fixes flash messages

* updates more deps

* bug fixes

* test fixes

* updates ember-cli-content-security-policy and prevents default form submission throwing errors

* more bug and test fixes

* removes commented out code

* fixes issue with code-mirror modifier sending change event on setup causing same computation error

* Upgrade Clean Up (#17543)

* updates deprecation workflow and filter

* cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest

* fixes control groups test that was skipped after upgrade

* updates control group service tests

* addresses review feedback

* updates control group service handleError method to use router.currentURL rather that transition.intent.url

* adds changelog entry
2022-10-18 09:46:02 -06:00

114 lines
4.1 KiB
JavaScript

import { click, currentRouteName, visit } from '@ember/test-helpers';
// TESTS HERE ARE SKPPED
// running vault with -dev-leased-kv flag lets you run some of these tests
// but generating leases programmatically is currently difficult
//
// TODO revisit this when it's easier to create leases
import { module, skip } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import secretList from 'vault/tests/pages/secrets/backend/list';
import secretEdit from 'vault/tests/pages/secrets/backend/kv/edit-secret';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import authPage from 'vault/tests/pages/auth';
import logout from 'vault/tests/pages/logout';
module('Acceptance | leases', function (hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(async function () {
await authPage.login();
this.enginePath = `kv-for-lease-${new Date().getTime()}`;
// need a version 1 mount for leased secrets here
return mountSecrets.visit().path(this.enginePath).type('kv').version(1).submit();
});
hooks.afterEach(function () {
return logout.visit();
});
const createSecret = async (context, isRenewable) => {
context.name = `secret-${new Date().getTime()}`;
await secretList.visitRoot({ backend: context.enginePath });
await secretList.create();
if (isRenewable) {
await secretEdit.createSecret(context.name, 'ttl', '30h');
} else {
await secretEdit.createSecret(context.name, 'foo', 'bar');
}
};
const navToDetail = async (context) => {
await visit('/vault/access/leases/');
await click(`[data-test-lease-link="${context.enginePath}/"]`);
await click(`[data-test-lease-link="${context.enginePath}/${context.name}/"]`);
await click(`[data-test-lease-link]:eq(0)`);
};
skip('it renders the show page', function (assert) {
createSecret(this);
navToDetail(this);
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.leases.show',
'a lease for the secret is in the list'
);
assert
.dom('[data-test-lease-renew-picker]')
.doesNotExist('non-renewable lease does not render a renew picker');
});
// skip for now until we find an easy way to generate a renewable lease
skip('it renders the show page with a picker', function (assert) {
createSecret(this, true);
navToDetail(this);
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.leases.show',
'a lease for the secret is in the list'
);
assert
.dom('[data-test-lease-renew-picker]')
.exists({ count: 1 }, 'renewable lease renders a renew picker');
});
skip('it removes leases upon revocation', async function (assert) {
createSecret(this);
navToDetail(this);
await click('[data-test-lease-revoke] button');
await click('[data-test-confirm-button]');
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.leases.list-root',
'it navigates back to the leases root on revocation'
);
await click(`[data-test-lease-link="${this.enginePath}/"]`);
await click('[data-test-lease-link="data/"]');
assert
.dom(`[data-test-lease-link="${this.enginePath}/data/${this.name}/"]`)
.doesNotExist('link to the lease was removed with revocation');
});
skip('it removes branches when a prefix is revoked', async function (assert) {
createSecret(this);
await visit(`/vault/access/leases/list/${this.enginePath}`);
await click('[data-test-lease-revoke-prefix] button');
await click('[data-test-confirm-button]');
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.leases.list-root',
'it navigates back to the leases root on revocation'
);
assert
.dom(`[data-test-lease-link="${this.enginePath}/"]`)
.doesNotExist('link to the prefix was removed with revocation');
});
skip('lease not found', async function (assert) {
await visit('/vault/access/leases/show/not-found');
assert
.dom('[data-test-lease-error]')
.hasText('not-found is not a valid lease ID', 'it shows an error when the lease is not found');
});
});