mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-23 07:31:09 +02:00
* 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
174 lines
6.7 KiB
JavaScript
174 lines
6.7 KiB
JavaScript
import { click, fillIn, findAll, currentURL, find, settled, waitUntil } from '@ember/test-helpers';
|
|
import { module, test } from 'qunit';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import authPage from 'vault/tests/pages/auth';
|
|
import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
|
|
|
|
module('Acceptance | ssh secret backend', function (hooks) {
|
|
setupApplicationTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
return authPage.login();
|
|
});
|
|
|
|
const PUB_KEY = `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn9p5dHNr4aU4R2W7ln+efzO5N2Cdv/SXk6zbCcvhWcblWMjkXf802B0PbKvf6cJIzM/Xalb3qz1cK+UUjCSEAQWefk6YmfzbOikfc5EHaSKUqDdE+HlsGPvl42rjCr28qYfuYh031YfwEQGEAIEypo7OyAj+38NLbHAQxDxuaReee1YCOV5rqWGtEgl2VtP5kG+QEBza4ZfeglS85f/GGTvZC4Jq1GX+wgmFxIPnd6/mUXa4ecoR0QMfOAzzvPm4ajcNCQORfHLQKAcmiBYMiyQJoU+fYpi9CJGT1jWTmR99yBkrSg6yitI2qqXyrpwAbhNGrM0Fw0WpWxh66N9Xp meirish@Macintosh-3.local`;
|
|
|
|
const ROLES = [
|
|
{
|
|
type: 'ca',
|
|
name: 'carole',
|
|
async fillInCreate() {
|
|
await click('[data-test-input="allowUserCertificates"]');
|
|
},
|
|
async fillInGenerate() {
|
|
await fillIn('[data-test-input="publicKey"]', PUB_KEY);
|
|
await click('[data-test-toggle-button]');
|
|
|
|
await click('[data-test-toggle-label="TTL"]');
|
|
await fillIn('[data-test-select="ttl-unit"]', 'm');
|
|
|
|
document.querySelector('[data-test-ttl-value="TTL"]').value = 30;
|
|
},
|
|
assertBeforeGenerate(assert) {
|
|
assert.dom('[data-test-form-field-from-model]').exists('renders the FormFieldFromModel');
|
|
let value = document.querySelector('[data-test-ttl-value="TTL"]').value;
|
|
// confirms that the actions are correctly being passed down to the FormFieldFromModel component
|
|
assert.strictEqual(value, '30', 'renders action updateTtl');
|
|
},
|
|
assertAfterGenerate(assert, sshPath) {
|
|
assert.strictEqual(
|
|
currentURL(),
|
|
`/vault/secrets/${sshPath}/sign/${this.name}`,
|
|
'ca sign url is correct'
|
|
);
|
|
assert.dom('[data-test-row-label="Signed key"]').exists({ count: 1 }, 'renders the signed key');
|
|
assert
|
|
.dom('[data-test-row-value="Signed key"]')
|
|
.exists({ count: 1 }, "renders the signed key's value");
|
|
assert.dom('[data-test-row-label="Serial number"]').exists({ count: 1 }, 'renders the serial');
|
|
assert.dom('[data-test-row-value="Serial number"]').exists({ count: 1 }, 'renders the serial value');
|
|
},
|
|
},
|
|
{
|
|
type: 'otp',
|
|
name: 'otprole',
|
|
async fillInCreate() {
|
|
await fillIn('[data-test-input="defaultUser"]', 'admin');
|
|
await click('[data-test-toggle-group="Options"]');
|
|
await fillIn('[data-test-input="cidrList"]', '1.2.3.4/32');
|
|
},
|
|
async fillInGenerate() {
|
|
await fillIn('[data-test-input="username"]', 'admin');
|
|
await fillIn('[data-test-input="ip"]', '1.2.3.4');
|
|
},
|
|
assertAfterGenerate(assert, sshPath) {
|
|
assert.strictEqual(
|
|
currentURL(),
|
|
`/vault/secrets/${sshPath}/credentials/${this.name}`,
|
|
'otp credential url is correct'
|
|
);
|
|
assert.dom('[data-test-row-label="Key"]').exists({ count: 1 }, 'renders the key');
|
|
assert.dom('[data-test-masked-input]').exists({ count: 1 }, 'renders mask for key value');
|
|
assert.dom('[data-test-row-label="Port"]').exists({ count: 1 }, 'renders the port');
|
|
assert.dom('[data-test-row-value="Port"]').exists({ count: 1 }, "renders the port's value");
|
|
},
|
|
},
|
|
];
|
|
test('ssh backend', async function (assert) {
|
|
assert.expect(26);
|
|
const now = new Date().getTime();
|
|
const sshPath = `ssh-${now}`;
|
|
|
|
await enablePage.enable('ssh', sshPath);
|
|
await settled();
|
|
await click('[data-test-configuration-tab]');
|
|
|
|
await click('[data-test-secret-backend-configure]');
|
|
|
|
assert.strictEqual(currentURL(), `/vault/settings/secrets/configure/${sshPath}`);
|
|
assert.ok(findAll('[data-test-ssh-configure-form]').length, 'renders the empty configuration form');
|
|
|
|
// default has generate CA checked so we just submit the form
|
|
await click('[data-test-ssh-input="configure-submit"]');
|
|
|
|
assert.ok(
|
|
await waitUntil(() => findAll('[data-test-ssh-input="public-key"]').length),
|
|
'a public key is fetched'
|
|
);
|
|
await click('[data-test-backend-view-link]');
|
|
|
|
assert.strictEqual(currentURL(), `/vault/secrets/${sshPath}/list`, `redirects to ssh index`);
|
|
|
|
for (let role of ROLES) {
|
|
// create a role
|
|
await click('[ data-test-secret-create]');
|
|
|
|
assert.ok(
|
|
find('[data-test-secret-header]').textContent.includes('SSH role'),
|
|
`${role.type}: renders the create page`
|
|
);
|
|
|
|
await fillIn('[data-test-input="name"]', role.name);
|
|
await fillIn('[data-test-input="keyType"]', role.type);
|
|
await role.fillInCreate();
|
|
await settled();
|
|
|
|
// save the role
|
|
await click('[data-test-role-ssh-create]');
|
|
await waitUntil(() => currentURL() === `/vault/secrets/${sshPath}/show/${role.name}`); // flaky without this
|
|
assert.strictEqual(
|
|
currentURL(),
|
|
`/vault/secrets/${sshPath}/show/${role.name}`,
|
|
`${role.type}: navigates to the show page on creation`
|
|
);
|
|
|
|
// sign a key with this role
|
|
await click('[data-test-backend-credentials]');
|
|
|
|
await role.fillInGenerate();
|
|
if (role.type === 'ca') {
|
|
await settled();
|
|
role.assertBeforeGenerate(assert);
|
|
}
|
|
|
|
// generate creds
|
|
await click('[data-test-secret-generate]');
|
|
await settled(); // eslint-disable-line
|
|
role.assertAfterGenerate(assert, sshPath);
|
|
|
|
// click the "Back" button
|
|
await click('[data-test-secret-generate-back]');
|
|
|
|
assert.ok(
|
|
findAll('[data-test-secret-generate-form]').length,
|
|
`${role.type}: back takes you back to the form`
|
|
);
|
|
|
|
await click('[data-test-secret-generate-cancel]');
|
|
|
|
assert.strictEqual(
|
|
currentURL(),
|
|
`/vault/secrets/${sshPath}/list`,
|
|
`${role.type}: cancel takes you to ssh index`
|
|
);
|
|
assert.ok(
|
|
findAll(`[data-test-secret-link="${role.name}"]`).length,
|
|
`${role.type}: role shows in the list`
|
|
);
|
|
|
|
//and delete
|
|
// TODO confirmed functionality works, but it can not find the data-test-ssh-role-delete in time.
|
|
// await click(`[data-test-secret-link="${role.name}"] [data-test-popup-menu-trigger]`);
|
|
// await settled();
|
|
// await click(`[data-test-ssh-role-delete]`);
|
|
// await settled();
|
|
// await click(`[data-test-confirm-button]`);
|
|
|
|
// await settled();
|
|
// assert
|
|
// .dom(`[data-test-secret-link="${role.name}"]`)
|
|
// .doesNotExist(`${role.type}: role is no longer in the list`);
|
|
}
|
|
});
|
|
});
|