c84d267c61
* Add Helios Design System Components (#19278) * adds hds dependency * updates reset import path * sets minifyCSS advanced option to false * Remove node-sass (#19376) * removes node-sass and fixes sass compilation * fixes active tab li class * Sidebar Navigation Components (#19446) * links ember-shared-components addon and imports styles * adds sidebar frame and nav components * updates HcNav component name to HcAppFrame and adds sidebar UserMenu component * adds tests for sidebar components * fixes tests * updates user menu styling * fixes typos in nav cluster component * changes padding value in sidebar stylesheet to use variable * Replace and remove old nav components with new ones (#19447) * links ember-shared-components addon and imports styles * adds sidebar frame and nav components * updates activeCluster on auth service and adds activeSession prop for sidebar visibility * replaces old nav components with new ones in templates * fixes sidebar visibility issue and updates user menu label class * removes NavHeader usage * adds clients index route to redirect to dashboard * removes unused HcAppFrame footer block and reduces page header top margin * Nav component cleanup (#19681) * removes nav-header components * removes navbar styling * removes status-menu component and styles * removes cluster and auth info components * removes menu-sidebar component and styling * fixes tests * Console Panel Updates (#19741) * updates console panel styling * adds test for opening and closing the console panel * updates console panel background color to use hds token * adds right margin to console panel input * updates link-status banner styling * updates hc nav components to new API * Namespace Picker Updates (#19753) * updates namespace-picker * updates namespace picker menu styling * adds bottom margin to env banner * updates class order on namespace picker link * restores manage namespaces refresh icon * removes manage namespaces nav icon * removes home link component (#20027) * Auth and Error View Updates (#19749) * adds vault logo to auth page * updates top level error template * updates loading substate handling and moves policies link from access to cluster nav (#20033) * moves console panel to bottom of viewport (#20183) * HDS Sidebar Nav Components (#20197) * updates nav components to hds * upgrades project yarn version to 3.5 * fixes issues in app frame component * updates sidenav actions to use icon button component * Sidebar navigation acceptance tests (#20270) * adds sidebar navigation acceptance tests and fixes other test failures * console panel styling tweaks * bumps addon version * remove and ignore yarn install-state file * fixes auth service and console tests * moves classes from deleted files after bulma merge * fixes sass syntax errors blocking build * cleans up dart sass deprecation warnings * adds changelog entry * hides namespace picker when sidebar nav panel is minimized * style tweaks * fixes sidebar nav tests * bumps hds addon to latest version and removes style override * updates modify-passthrough-response helper * updates sidebar nav tests * mfa-setup test fix attempt * fixes cluster mfa setup test * remove deprecated yarn ignore-optional flag from makefile * removes another instance of yarn ignore-optional and updates ui readme * removes unsupported yarn verbose flag from ci-helper * hides nav headings when user does not have access to any sub links * removes unused optional deps and moves lint-staged to dev deps * updates has-permission helper and permissions service tests * fixes issue with console panel not filling container width
102 lines
5.9 KiB
JavaScript
102 lines
5.9 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { create } from 'ember-cli-page-object';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
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 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 (path) {
|
|
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 () {
|
|
const path = `userpass-${uuidv4()}`;
|
|
await authPage.login();
|
|
await setupUser(path);
|
|
await authPage.logout();
|
|
await authPage.loginUsername(USER, PASSWORD, path);
|
|
await click('[data-test-user-menu-trigger]');
|
|
await click('[data-test-user-menu-item="mfa"]');
|
|
});
|
|
|
|
test('it should login through MFA and post to 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/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/rvJRxsZAwEC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JAkDAQJIyXeMiKG0fY9R3T+EOFmydVtTs1XyVOg4WEgSBhIEgYL+/LUtmt7ZvGD9x3iXRnSt381Hm583nqBwsJA0HCQJAwXupDXLozLrcuvXvur67v1pOovk3dj6hnbnfzxELCQJAwECSM2+8x7HDX8Op+t76iQvUd1Ty6+9zc32ku8QcWkgeChIEgYUgx9YvdM69qHDeu0s2z6mfqM9R8rt0zPfYhgSBIGAgShpTb+y52fYQbl1nbuXlm1efqPkXxaVhIGAgSBoKEcdSHnM7Vre5zx1Ovu59PaxLJy/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/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.');
|
|
});
|
|
});
|