mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 12:07:02 +02:00
* OIDC Config Routing (#16028) * adds oidc config routes * renames oidc applications route to clients * UI/vault 6646/landing page (#16069) * add to sidebar * add landing image and text * add permissions * add permissions to permissions service * remove comment * fix. * UI/OIDC models (#16091) * add models and fix routing * add ClientsCreate route * remove form functions from client model * update comment * address comments, cleanup models * add comment * OIDC Adapters and Serializers (#16120) * adds named-path base adapter * adds oidc adapters with tests * adds oidc serializers * fixes issue with supported_scopes relationship in oidc provider model * make radio card size flex (#16125) * OIDC config details routes (#16126) * adds details routes for oidc config resources * adds details templates for oidc config resources * OIDC parent route and index redirection (#16139) * adds parent oidc route with header and adds redirection if clients have been created * updates learn link * adds findRecord override to named-path adapter (#16145) * OIDC Scope Create/Edit View (#16174) * adds oidc scope-form to create and edit views * moves oidc header set logic from route to controller * OIDC Scope Details View (#16191) * adds oidc scope details view * removes disabled arg from scope delete confirm action * updates oidc scope template params link to use DocLink and adds success message on scope create success * updates oidc scope delete confirm action copy * adds oidc scopes list (#16196) * UI/vault 6655/OIDC create view (#16331) * setup header * wip * wip * wip * validations * error validations * cleanup * wip * fix error * clean up * handle modelValidations * add documentation on the decorator * remove spread attrs * first test and some fixes * halfway with test * fix error where the data object was sending param entiyIds and not entity_ids * validations or situation * fix test * small nit: * test if this fixes the test * fix * cleanup * nit * Assignments Update/Edit View (#16412) * wip * fix * render search-select after promise is fulfilled * add test coverage Co-authored-by: clairebontempo@gmail.com <cbontempo@hashicorp.com> * Added list view for keys (#16454) * Added list view for providers (#16442) * Added list view for providers * Removed check for model data length * Added new line at end of file * Fixed linting issues causing ui tests to fail * Added list view for application (#16469) * UI/remove has many relationship (#16470) * remove hasMany from models * remove relationships from assignments create form * update tests * Assignment list view (#16340) * inital setup * handle default allow all * add learn more link * Fixed the default allow_all for assignment list view to match Figma design * Fixed linting * Fixed hbs file syntax Co-authored-by: linda9379 <linda.jiang@hashicorp.com> * configure mirage and helper (#16482) * UI/OIDC client form (#16131) * WIP client form * wip * still WIP * fix form!; * remove computeds, cache form attrs instead * update scope form component name * add white space validation * add validations, cleanup * add edit form * fix link to in edit form * disable edit form * fix linkto * wip/ search select filter * WIP/search-select bug * fix assignment save * delete old modal js file * glimmerize/create new search select modal component * component cleanup * fix bugginess * fix search select and radio select action * add tests * revert some test changes * oops, removed test tag * add key list to response * fix test * move search select component to separate PR, revert changes * one more revert * remove oidc helper from this pr * remove hasMany relationship * minor cleanup * update assignment form to use fallback * fix allow_all appearing in dropdown on edit (#16508) * UI/ OIDC Application (client) details view (#16507) * fix test * finish details page * finish details view * clean u[ * fix typo * configure oidc mirage handler for tests * remove params, add new route instead * fix headers * remove console.log * remove controller/template reliance on tracked variable * rename variable * UI/Client route acceptance tests - fixed branch (#16654) * WIP client route tests * refactor client form so clientType is not edit-able * fix ttl in client form * wip// more acceptance tests and tags for hbs files * fix typo * fix syntax error * finish tests * fix client form test * resolve commits * update form test * OIDC Assignments Details view. (#16511) * setup * cleanup * view all fix * wip setting up tabs * wip * revert to no queryParam or tabs * add the read more component and styling * rename folder * cleanup * fix * UI/OIDC providers create/edit route (#16612) * update to use DocLink component * provider create form * cleaup * add formt est * revert label text * update doclink test * disallow new scopes from ss * fix test typo * fix provider form flash message * add period * test new form field attr * refactor form input * fix edit portion of issuer field * add test selector to new input field * add comment * Cleanup OIDC Config Mirage handler (#16674) * cleaup mirage * change to .then * pull out into config file * Scope acceptance tests (#16707) * Started writing acceptance tests * Added some more acceptance tests * Added tags for hbs and more tests * Modified variable names in scope form test * Fixed tests and linting * UI/OIDC Provider read view (#16632) * add providers/provider/client route * provider details view * add disabled button and tooltip for default * add toolbar separators * revert unrelated change * query all client records and filter by allowed client id" * refactor adapter to filter for clientId * cleanup adapter method * update test * refactor test * fix tests to accommodate for serializer change * update empty state message * fix linting * metadata for client list view (#16725) * Added metadata for list view in clients * Fixed linting * Fixed failing ui test * fix scopes and clients tests (#16768) * Initial fix of tests * Fixed failing scopes and clients acceptance tests * Fixed linting * UI: Key create/edit form (#16729) * add route models * add forms * add test * remove helperText attr * metadata for provider list view (#16738) * Added meta-data for provider list view * Added comment for serializer * Fixed import path for scopes and clients acceptance test files * UI/Add client ids to search select (#16744) * WIP use clientID instead of name * add client ids to search select * remove provider form component changes * fix search select on edit * cleanup comments and method * fix adapter query method * clean up comments * add test * remove destructuring so linting passes * fix tests * add accidentally deleted param * add clarifying comments * cleanup * change how shouldRenderName is set * cleanup tests * address comments * OIDC Assignment Acceptance tests (#16741) * test and fixes * merge stuff * fix * fixes * add waituntil * inconsistent nav issue * fixes * blah * UI/Key details view (#16776) * add details view * reformat model file * todo for when listing applications * add comment * update key form with refactored search select * add applications list * update test * update test * add names to flash messages * add rollbackAttributes to delete catch (#16796) * UI: Checks if records exists before creating record when URL contains :name (#16823) * check for record existing in createRecord * use error banner instead of flash messages for forms * add inline form message for validations * add error count message to inlinealert * add test for adapter * add tests * remove unused vars * UI: Disable limiting clients when creating key, filter clients when editing (#16926) * add tooltip to disabled radio button * pass query object to search select * update copy * add comment * cleanup console log and comment * fix tests * revert change because addressed in other pr * fix diff * fix test * UI: Add redirect when last client is deleted (#16927) * afterModel redirect if no models exist * fix test * change space * fix incorrect text * UI: Add InfoTooltip to selected 'ghost' client_ids (#16942) * return option if undefined * add info tooltip to search select * change word * add test * UI: OIDC config keys acceptance tests (#16968) * add keys test * update other oidc tests * remove-search select comment * UI: Filter Client providers list view (#17027) * pass param to adapter * add test * UI: OIDC Config Acceptance Tests (#17050) * WIP/provider acceptance tests" * WIP/this commit breaks lots of things * fix tests * update test selectors * combine key and client tests * cleanup clients and keys test * finish tests * small tidying * UI: Remove trailing comma from scopes, provider details page (#17069) * use info table row to cleanup scope logic * infotableitemarray cleanup * tidying * add changelog * teeny little empty state * fix wildcard string helper not working Co-authored-by: Jordan Reimer <zofskeez@gmail.com> Co-authored-by: Angel Garbarino <Monkeychip@users.noreply.github.com> Co-authored-by: Angel Garbarino <argarbarino@gmail.com> Co-authored-by: linda9379 <57650314+linda9379@users.noreply.github.com> Co-authored-by: linda9379 <linda.jiang@hashicorp.com>
252 lines
9.2 KiB
JavaScript
252 lines
9.2 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render, fillIn, click, findAll } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { create } from 'ember-cli-page-object';
|
|
import { clickTrigger } from 'ember-power-select/test-support/helpers';
|
|
import ss from 'vault/tests/pages/components/search-select';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import ENV from 'vault/config/environment';
|
|
import {
|
|
OIDC_BASE_URL,
|
|
SELECTORS,
|
|
overrideMirageResponse,
|
|
overrideCapabilities,
|
|
} from 'vault/tests/helpers/oidc-config';
|
|
|
|
const searchSelect = create(ss);
|
|
|
|
module('Integration | Component | oidc/client-form', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.before(function () {
|
|
ENV['ember-cli-mirage'].handler = 'oidcConfig';
|
|
});
|
|
|
|
hooks.after(function () {
|
|
ENV['ember-cli-mirage'].handler = null;
|
|
});
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.server.post('/sys/capabilities-self', () => {});
|
|
this.server.get('/identity/oidc/key', () => {
|
|
return {
|
|
request_id: 'key-list-id',
|
|
data: {
|
|
keys: ['default'],
|
|
},
|
|
};
|
|
});
|
|
this.server.get('/identity/oidc/assignment', () => {
|
|
return {
|
|
request_id: 'assignment-list-id',
|
|
data: {
|
|
keys: ['allow_all', 'assignment-1'],
|
|
},
|
|
};
|
|
});
|
|
this.server.get('/identity/oidc/assignment/assignment-1', () => {
|
|
return {
|
|
request_id: 'assignment-1-id',
|
|
data: {
|
|
entity_ids: ['1234-12345'],
|
|
group_ids: ['abcdef-123'],
|
|
},
|
|
};
|
|
});
|
|
});
|
|
|
|
test('it should save new client', async function (assert) {
|
|
assert.expect(14);
|
|
|
|
this.server.post('/identity/oidc/client/test-app', (schema, req) => {
|
|
assert.ok(true, 'Request made to save client');
|
|
return JSON.parse(req.requestBody);
|
|
});
|
|
this.model = this.store.createRecord('oidc/client');
|
|
this.onSave = () => assert.ok(true, 'onSave callback fires on save success');
|
|
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
await click('[data-test-toggle-group="More options"]');
|
|
assert
|
|
.dom('[data-test-oidc-client-title]')
|
|
.hasText('Create application', 'Form title renders correct text');
|
|
assert.dom(SELECTORS.clientSaveButton).hasText('Create', 'Save button has correct text');
|
|
assert.equal(findAll('[data-test-field]').length, 6, 'renders all attribute fields');
|
|
assert.dom('input#allow-all').isChecked('Allow all radio button selected by default');
|
|
assert.dom('[data-test-ttl-value="ID Token TTL"]').hasValue('1', 'ttl defaults to 24h');
|
|
assert.dom('[data-test-ttl-value="Access Token TTL"]').hasValue('1', 'ttl defaults to 24h');
|
|
assert.dom('[data-test-selected-option]').hasText('default', 'Search select has default key selected');
|
|
|
|
// check validation errors
|
|
await fillIn('[data-test-input="name"]', ' ');
|
|
await click('[data-test-selected-list-button="delete"]');
|
|
await click(SELECTORS.clientSaveButton);
|
|
|
|
let validationErrors = findAll(SELECTORS.inlineAlert);
|
|
assert
|
|
.dom(validationErrors[0])
|
|
.hasText('Name is required. Name cannot contain whitespace.', 'Validation messages are shown for name');
|
|
assert.dom(validationErrors[1]).hasText('Key is required.', 'Validation message is shown for key');
|
|
assert.dom(validationErrors[2]).hasText('There are 3 errors with this form.', 'Renders form error count');
|
|
|
|
// fill out form with valid inputs
|
|
await clickTrigger();
|
|
await fillIn('.ember-power-select-search input', 'default');
|
|
await searchSelect.options.objectAt(0).click();
|
|
|
|
await click('label[for=limited]');
|
|
assert
|
|
.dom('[data-test-search-select-with-modal]')
|
|
.exists('Limited radio button shows assignments search select');
|
|
|
|
await clickTrigger();
|
|
assert.dom('li.ember-power-select-option').hasText('assignment-1', 'dropdown renders assignments');
|
|
await fillIn('[data-test-input="name"]', 'test-app');
|
|
await click(SELECTORS.clientSaveButton);
|
|
});
|
|
|
|
test('it should update client', async function (assert) {
|
|
assert.expect(11);
|
|
|
|
this.server.post('/identity/oidc/client/test-app', (schema, req) => {
|
|
assert.ok(true, 'Request made to save client');
|
|
return JSON.parse(req.requestBody);
|
|
});
|
|
|
|
this.store.pushPayload('oidc/client', {
|
|
modelName: 'oidc/client',
|
|
name: 'test-app',
|
|
clientType: 'public',
|
|
});
|
|
|
|
this.model = this.store.peekRecord('oidc/client', 'test-app');
|
|
this.onSave = () => assert.ok(true, 'onSave callback fires on save success');
|
|
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
await click('[data-test-toggle-group="More options"]');
|
|
assert.dom('[data-test-oidc-client-title]').hasText('Edit application', 'Title renders correct text');
|
|
assert.dom(SELECTORS.clientSaveButton).hasText('Update', 'Save button has correct text');
|
|
assert.dom('[data-test-input="name"]').isDisabled('Name input is disabled when editing');
|
|
assert.dom('[data-test-input="name"]').hasValue('test-app', 'Name input is populated with model value');
|
|
assert.dom('[data-test-input="key"]').isDisabled('Signing key input is disabled');
|
|
assert.dom('[data-test-input="key"]').hasValue('default', 'Key input populated with default');
|
|
assert.dom('[data-test-input="clientType"] input').isDisabled('client type input is disabled on edit');
|
|
assert
|
|
.dom('[data-test-input="clientType"] input#confidential')
|
|
.isChecked('Correct radio button is selected');
|
|
assert.dom('input#allow-all').isChecked('Allow all radio button is selected');
|
|
await click(SELECTORS.clientSaveButton);
|
|
});
|
|
|
|
test('it should rollback attributes or unload record on cancel', async function (assert) {
|
|
assert.expect(4);
|
|
this.model = this.store.createRecord('oidc/client');
|
|
this.onCancel = () => assert.ok(true, 'onCancel callback fires');
|
|
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
|
|
await click(SELECTORS.clientCancelButton);
|
|
assert.true(this.model.isDestroyed, 'New model is unloaded on cancel');
|
|
|
|
this.store.pushPayload('oidc/client', {
|
|
modelName: 'oidc/client',
|
|
name: 'test-app',
|
|
assignments: ['allow_all'],
|
|
redirectUris: [],
|
|
});
|
|
this.model = this.store.peekRecord('oidc/client', 'test-app');
|
|
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
|
|
await fillIn('[data-test-input="redirectUris"] [data-test-string-list-input="0"]', 'some-url.com');
|
|
await click('[data-test-string-list-button="add"]');
|
|
await click(SELECTORS.clientCancelButton);
|
|
assert.equal(this.model.redirectUris, undefined, 'Model attributes rolled back on cancel');
|
|
});
|
|
|
|
test('it should show create assignment modal', async function (assert) {
|
|
assert.expect(2);
|
|
this.model = this.store.createRecord('oidc/client');
|
|
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
<div id="modal-wormhole"></div>
|
|
`);
|
|
await click('label[for=limited]');
|
|
await clickTrigger();
|
|
await fillIn('.ember-power-select-search input', 'test-new');
|
|
await searchSelect.options.objectAt(0).click();
|
|
assert.dom('[data-test-modal-title]').hasText('Create new assignment', 'Create assignment modal renders');
|
|
await click(SELECTORS.assignmentCancelButton);
|
|
assert.dom('[data-test-modal-div]').doesNotExist('Modal disappears after clicking cancel');
|
|
});
|
|
|
|
test('it should render fallback for search select', async function (assert) {
|
|
assert.expect(1);
|
|
this.model = this.store.createRecord('oidc/client');
|
|
this.server.get('/identity/oidc/assignment', () => overrideMirageResponse(403));
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
|
|
await click('label[for=limited]');
|
|
assert
|
|
.dom('[data-test-component="string-list"]')
|
|
.exists('Radio toggle shows assignments string-list input');
|
|
});
|
|
|
|
test('it should render error alerts when API returns an error', async function (assert) {
|
|
assert.expect(2);
|
|
this.model = this.store.createRecord('oidc/client');
|
|
this.server.post('/sys/capabilities-self', () => overrideCapabilities(OIDC_BASE_URL + '/clients'));
|
|
await render(hbs`
|
|
<Oidc::ClientForm
|
|
@model={{this.model}}
|
|
@onCancel={{this.onCancel}}
|
|
@onSave={{this.onSave}}
|
|
/>
|
|
`);
|
|
await fillIn('[data-test-input="name"]', 'test-app');
|
|
await click(SELECTORS.clientSaveButton);
|
|
assert
|
|
.dom(SELECTORS.inlineAlert)
|
|
.hasText('There was an error submitting this form.', 'form error alert renders ');
|
|
assert.dom('[data-test-alert-banner="alert"]').exists('alert banner renders');
|
|
});
|
|
});
|