mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 12:37:02 +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
98 lines
5.9 KiB
JavaScript
98 lines
5.9 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { create } from 'ember-cli-page-object';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import { click, fillIn } from '@ember/test-helpers';
|
|
import authPage from 'vault/tests/pages/auth';
|
|
import enablePage from 'vault/tests/pages/settings/auth/enable';
|
|
import logout from 'vault/tests/pages/logout';
|
|
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
const consoleComponent = create(consoleClass);
|
|
const USER = 'end-user';
|
|
const PASSWORD = 'mypassword';
|
|
const POLICY_NAME = 'identity_policy';
|
|
|
|
const writePolicy = async function (path) {
|
|
await enablePage.enable('userpass', path);
|
|
const identityPolicy = `path "identity/*" {
|
|
capabilities = ["create", "read", "update", "delete", "list"]
|
|
}`;
|
|
await consoleComponent.runCommands([
|
|
`write sys/policies/acl/${POLICY_NAME} policy=${btoa(identityPolicy)}`,
|
|
]);
|
|
};
|
|
|
|
const writeUserWithPolicy = async function (path) {
|
|
await consoleComponent.runCommands([
|
|
`write auth/${path}/users/${USER} password=${PASSWORD} policies=${POLICY_NAME}`,
|
|
]);
|
|
};
|
|
|
|
const setupUser = async function () {
|
|
let path = `userpass-${new Date().getTime()}`;
|
|
await writePolicy(path);
|
|
await writeUserWithPolicy(path);
|
|
await click('[data-test-save-config="true"]');
|
|
};
|
|
|
|
module('Acceptance | mfa-setup', function (hooks) {
|
|
setupApplicationTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(async function () {
|
|
await logout.visit();
|
|
await authPage.login('root');
|
|
await setupUser();
|
|
await logout.visit();
|
|
await authPage.loginUsername(USER, PASSWORD);
|
|
await click('.nav-user-button button');
|
|
await click('[data-test-status-link="mfa"]');
|
|
});
|
|
|
|
test('it should login through MFA and post to admin-generate and be able to restart the setup', async function (assert) {
|
|
assert.expect(5);
|
|
// the network requests required in this test
|
|
this.server.post('/identity/mfa/method/totp/admin-generate', (scheme, req) => {
|
|
const json = JSON.parse(req.requestBody);
|
|
assert.strictEqual(json.method_id, '123', 'sends the UUID value');
|
|
return {
|
|
data: {
|
|
barcode:
|
|
'iVBORw0KGgoAAAANSUhEUgAAAMgAAADIEAAAAADYoy0BAAAGbUlEQVR4nOydUW7kOAxEk0Xuf+VZzABepAXTrKLUmMrivY8AacuSkgJFSyTdX79+fUAQ//ztCcArX79/fH7Oblat6+q/a7+2c++r5qX+fdU4av/rvF1+34+FhIEgYSBIGF/ff3F9gtuuW4u7Nbi6v1v7q36nT5i7PumpPywkDAQJA0HC+Lr7sFoj3ef0bj/h+gR13PX3ype4+4tufHWe1XgfWEgeCBIGgoRx60OmVGute/aj+oaq/a5vWXHnswMWEgaChIEgYRz1IRfdc7e65rrP/9Var/oKN47yjmgrFhIGgoSBIGHc+pDdOMGpOMPanxprX8+qVF/S+aBqXh3O/wMLCQNBwkCQMF58yDSf6KJbqzsf4LZf5z3tz92nqD5l8v/EQsJAkDAQJIw/PuRdGfDdc37X/sI9g+rG7/7eqS/r5qOAhYSBIGEgSBgv9SFufUN3xqSeHU2f36fxCjVuosbaT9ajYCFhIEgYCBLG7VnW9Axomv+krunV9RX3jErFzQ+bjIuFhIEgYSBIGLc1htMzp1P14ru+rPM9Fe5+5FRM/ft4WEgYCBIGgoTxGFPv6j2qWr21v2lsXPUF0zOrFfUMa/ouFsWnYiFhIEgYCBLG47tOurVvWoe+G5verT85lUOgnpk5NZZYSBgIEgaChHGbl+XGvt19htrvivu8r67t3bynOb/rvJRxsZAwECQMBAnj8/v6peY5vTtWvZsn5tYAuvld7j7M8ZFYSBgIEgaChPF5t85On9/d+MDKbr7V6TqXaTxE3UexD/kBIEgYCBLG4/eHTHNV1Rxg9Qyp69dl+nepuctVewUsJAwECQNBwrDelzWNHVf3d3T1J7vz7eY1zSFW+78DCwkDQcJAkDBuz7LKxhv5RnecWnvds7fqczWvTL3ezfPucywkDAQJA0HCePwOKrcOY7pPmPY/9R0V3b5nW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l1nbuXlm1efqPkXxaVhIGAgSBoKEcdSHnM7Vre5zx1Ovu59PaxLJy/pBIEgYCBLG47vfVdw68hV3LXfnNZ2Put/YnQ9nWcEgSBgIEsbjOxdVujOad7wT5MR907OobvxpbsIHFpIHgoSBIGHcfn8I/D2wkDD+DQAA//8FNJPArbdKOwAAAABJRU5ErkJggg==',
|
|
url: 'otpauth://totp/Vault:26606dbe-d8ea-82ca-41b0-1250a4484079?algorithm=SHA1&digits=6&issuer=Vault&period=30&secret=FID3WRPRRADQDN3CGPVVOLKCXTZZPSML',
|
|
lease_duration: 0,
|
|
},
|
|
};
|
|
});
|
|
this.server.post('/identity/mfa/method/totp/admin-destroy', (scheme, req) => {
|
|
const json = JSON.parse(req.requestBody);
|
|
assert.strictEqual(json.method_id, '123', 'sends the UUID value');
|
|
// returns nothing
|
|
return {};
|
|
});
|
|
await fillIn('[data-test-input="uuid"]', 123);
|
|
await click('[data-test-verify]');
|
|
assert.dom('[data-test-qrcode]').exists('the qrCode is shown.');
|
|
assert.dom('[data-test-mfa-enabled-warning]').doesNotExist('warning does not show.');
|
|
await click('[data-test-restart]');
|
|
assert.dom('[data-test-step-one]').exists('back to step one.');
|
|
});
|
|
|
|
test('it should show a warning if you enter in the same UUID without restarting the setup', async function (assert) {
|
|
assert.expect(2);
|
|
// the network requests required in this test
|
|
this.server.post('/identity/mfa/method/totp/admin-generate', () => {
|
|
return {
|
|
data: null,
|
|
warnings: ['Entity already has a secret for MFA method “”'],
|
|
};
|
|
});
|
|
|
|
await fillIn('[data-test-input="uuid"]', 123);
|
|
await click('[data-test-verify]');
|
|
assert.dom('[data-test-qrcode]').doesNotExist('the qrCode is not shown.');
|
|
assert.dom('[data-test-mfa-enabled-warning]').exists('the mfa-enabled warning shows.');
|
|
});
|
|
});
|