mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 03:57:01 +02:00
* adds ldap ember engine (#20786) * adds ldap as mountable and supported secrets engine (#20793) * removes active directory as mountable secrets engine (#20798) * LDAP Config Ember Data Setup (#20863) * adds secret-engine-path adapter * adds model, adapater and serializer for ldap config * adds test for ldap config adapter * addresses PR feedback * updates remaining instances of getURL in secrets-engine-path adapter * adds underscore to getURL method in kubernetes/config adapter * adds check config vars test for kubernetes/config adapter * adds comment regarding primaryKey in secrets-engine-path adapter * adds tab-page-header component for ldap secrets engine (#20941) * LDAP Config Route (#21059) * converts secret-mount-path service to ts and moves kubernetes fetch-config decorator to core addon and converts to ts * adds ldap config route * fixes withConfig import path in kubernetes roles route * updates types in ldap config route * adds unit tests for fetch-secret-config decorator * updates comments in fetch-secret-config decorator * renames fetch-secret-config decorator * LDAP Configure Page Component (#21384) * adds ldap page configure component * removes pauseTest and updates radio card selector in ldap config test * LDAP Configuration (#21430) * adds ldap configuration route * adds secrets-engine-mount-config component to core addon * adds ldap config-cta component * adds display fields to ldap configuration page and test * fixes ldap config-cta test * adds yield to secrets-engine-mount-config component * fixes tests * LDAP Overview Route and Page Component (#21579) * adds ldap overview route and page component * changes toolbar link action type for create role on overview page * LDAP Role Model, Adapter and Serializer (#21655) * adds model, adapter and serializer for ldap roles * addresses review feedback * changes ldap role type from tracked prop to attr and sets in adapter for query methods * adds assertions to verify that frontend only props are returned from query methods in ldap role adapter * LDAP Library Model, Adapter and Serializer (#21728) * adds model, adapter and serializer for ldap library * updates capitalization and punction for ldap role and library form fields * LDAP Roles Create and Edit (#21818) * moves stringify and jsonify helpers to core addon * adds validation error for ttl picker in form field component * adds ldap roles create and edit routes and page component * adds ldap mirage handler and factory for roles * adds example workflow to json editor component * adds tests for ldap page create and edit component * addresses feedback * LDAP Role Details (#22036) * adds ldap role route to pass down model to child routes * adds ldap role details route and page component * updates ldap role model capabilities checks * adds periods to error messages * removes modelFor from ldap roles edit and details routes * adds flash message on ldap role delete success * LDAP Roles (#22070) * adds ldap roles route and page component * update ldap role adapter tests and adds adapter options to query for partialErrorInfo * updates ldap role adapter based on PR feedback * adds filter-input component to core addon * updates ldap roles page to use filter-input component * updates ldap role adapter tests * LDAP Role Credentials (#22142) * adds ldap roles route and page component * update ldap role adapter tests and adds adapter options to query for partialErrorInfo * adds credentials actions to ldap roles list menu and fixes rotate action in details view * adds ldap role credentials route and page component * adds tests for ldap role credentials * LDAP Library Create and Edit (#22171) * adds ldap library create/edit routes and page component * adds ldap library create-and-edit tests and library mirage factory * updates form-field component to display validation errors and warnings for all fields * updates ldap library edit route class name * updates ldap library model interface name * adds missing period in flash message * LDAP Libraries (#22184) * updates interface and class names in ldap roles route * adds ldap libraries route and page component * fixes lint error * LDAP Library Details (#22200) * updates interface and class names in ldap roles route * adds ldap libraries route and page component * fixes lint error * adds ldap library details route and page component * LDAP Library Details Configuration (#22201) * updates interface and class names in ldap roles route * adds ldap libraries route and page component * fixes lint error * adds ldap library details route and page component * adds ldap library details configuration route and page component * updates ldap library check-in enforcement value mapping * fixes issue in code mirror modifier after merging upgrade * fixes failing database secrets test * LDAP Library Account Details (#22287) * adds route and page component for ldap library accounts * adds ldap component for checked out accounts * updates ldap library adapter tests * LDAP Library Check-out (#22289) * adds route and page component for ldap library accounts * adds ldap component for checked out accounts * adds route and page component for ldap library checkout * addresses PR feedback * LDAP Overview Cards (#22325) * adds overview cards to ldap overview route * adds create library toolbar action to ldap overview route * adds acceptance tests for ldap workflows (#22375) * Fetch Secrets Engine Config Decorator Docs (#22416) * removes uneccesary asyncs from ldap route model hooks * updates ldap overview route class name * adds documentation for fetch-secrets-engine-config decorator * add changelog * adding back external links, missed due to merge. * changelog * fix test after merging in dashboard work * Update 20790.txt --------- Co-authored-by: Angel Garbarino <angel@hashicorp.com> Co-authored-by: Angel Garbarino <Monkeychip@users.noreply.github.com>
198 lines
6.9 KiB
JavaScript
198 lines
6.9 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import { render, click, fillIn } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import sinon from 'sinon';
|
|
|
|
module('Integration | Component | ldap | Page::Role::CreateAndEdit', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'ldap');
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
const router = this.owner.lookup('service:router');
|
|
const routerStub = sinon.stub(router, 'transitionTo');
|
|
this.transitionCalledWith = (routeName, name) => {
|
|
const route = `vault.cluster.secrets.backend.ldap.${routeName}`;
|
|
const args = name ? [route, name] : [route];
|
|
return routerStub.calledWith(...args);
|
|
};
|
|
|
|
this.store = this.owner.lookup('service:store');
|
|
this.newModel = this.store.createRecord('ldap/role', { backend: 'ldap-test' });
|
|
|
|
['static', 'dynamic'].forEach((type) => {
|
|
this[`${type}RoleData`] = this.server.create('ldap-role', type, { name: `${type}-role` });
|
|
this.store.pushPayload('ldap/role', {
|
|
modelName: 'ldap/role',
|
|
backend: 'ldap-test',
|
|
type,
|
|
...this[`${type}RoleData`],
|
|
});
|
|
});
|
|
|
|
this.breadcrumbs = [
|
|
{ label: 'ldap', route: 'overview' },
|
|
{ label: 'roles', route: 'roles' },
|
|
{ label: 'create' },
|
|
];
|
|
|
|
this.renderComponent = () => {
|
|
return render(
|
|
hbs`<Page::Role::CreateAndEdit @model={{this.model}} @breadcrumbs={{this.breadcrumbs}} />`,
|
|
{ owner: this.engine }
|
|
);
|
|
};
|
|
});
|
|
|
|
test('it should display different form fields based on type', async function (assert) {
|
|
assert.expect(12);
|
|
|
|
this.model = this.newModel;
|
|
await this.renderComponent();
|
|
|
|
assert.dom('[data-test-radio-card="static"]').isChecked('Static role type selected by default');
|
|
|
|
const checkFields = (fields) => {
|
|
fields.forEach((field) => {
|
|
assert
|
|
.dom(`[data-test-field="${field}"]`)
|
|
.exists(`${field} field renders when static type is selected`);
|
|
});
|
|
};
|
|
|
|
checkFields(['name', 'dn', 'username', 'rotation_period']);
|
|
await click('[data-test-radio-card="dynamic"]');
|
|
checkFields([
|
|
'name',
|
|
'default_ttl',
|
|
'max_ttl',
|
|
'username_template',
|
|
'creation_ldif',
|
|
'deletion_ldif',
|
|
'rollback_ldif',
|
|
]);
|
|
});
|
|
|
|
test('it should populate form and disable type cards when editing', async function (assert) {
|
|
assert.expect(12);
|
|
|
|
const checkFields = (fields, element = 'input:last-child') => {
|
|
fields.forEach((field) => {
|
|
const isLdif = field.includes('ldif');
|
|
const method = isLdif ? 'includesText' : 'hasValue';
|
|
const value = isLdif ? 'dn: cn={{.Username}},ou=users,dc=learn,dc=example' : this.model[field];
|
|
assert.dom(`[data-test-field="${field}"] ${element}`)[method](value, `${field} field value renders`);
|
|
});
|
|
};
|
|
const checkTtl = (fields) => {
|
|
fields.forEach((field) => {
|
|
assert
|
|
.dom(`[data-test-field="${field}"] [data-test-ttl-inputs] input`)
|
|
.hasAnyValue(`${field} field ttl value renders`);
|
|
});
|
|
};
|
|
|
|
this.model = this.store.peekRecord('ldap/role', 'static-role');
|
|
await this.renderComponent();
|
|
assert.dom('[data-test-radio-card="static"]').isDisabled('Type selection is disabled when editing');
|
|
checkFields(['name', 'dn', 'username']);
|
|
checkTtl(['rotation_period']);
|
|
|
|
this.model = this.store.peekRecord('ldap/role', 'dynamic-role');
|
|
await this.renderComponent();
|
|
checkFields(['name', 'username_template']);
|
|
checkTtl(['default_ttl', 'max_ttl']);
|
|
checkFields(['creation_ldif', 'deletion_ldif', 'rollback_ldif'], '.CodeMirror-code');
|
|
});
|
|
|
|
test('it should go back to list route and clean up model on cancel', async function (assert) {
|
|
this.model = this.store.peekRecord('ldap/role', 'static-role');
|
|
const spy = sinon.spy(this.model, 'rollbackAttributes');
|
|
|
|
await this.renderComponent();
|
|
await click('[data-test-cancel]');
|
|
|
|
assert.ok(spy.calledOnce, 'Model is rolled back on cancel');
|
|
assert.ok(this.transitionCalledWith('roles'), 'Transitions to roles list route on cancel');
|
|
});
|
|
|
|
test('it should validate form fields', async function (assert) {
|
|
const renderAndAssert = async (fields) => {
|
|
await this.renderComponent();
|
|
await click('[data-test-save]');
|
|
|
|
fields.forEach((field) => {
|
|
assert
|
|
.dom(`[data-test-field="${field}"] [data-test-inline-error-message]`)
|
|
.exists('Validation message renders');
|
|
});
|
|
|
|
assert
|
|
.dom('[data-test-invalid-form-message]')
|
|
.hasText(`There are ${fields.length} errors with this form.`);
|
|
};
|
|
|
|
this.model = this.newModel;
|
|
await renderAndAssert(['name', 'username', 'rotation_period']);
|
|
|
|
await click('[data-test-radio-card="dynamic"]');
|
|
await renderAndAssert(['name', 'creation_ldif', 'deletion_ldif']);
|
|
});
|
|
|
|
test('it should create new role', async function (assert) {
|
|
assert.expect(2);
|
|
|
|
this.server.post('/ldap-test/static-role/test-role', (schema, req) => {
|
|
const data = JSON.parse(req.requestBody);
|
|
const expected = { dn: 'foo', username: 'bar', rotation_period: '5s' };
|
|
assert.deepEqual(data, expected, 'POST request made with correct properties when creating role');
|
|
});
|
|
|
|
this.model = this.newModel;
|
|
await this.renderComponent();
|
|
|
|
await fillIn('[data-test-input="name"]', 'test-role');
|
|
await fillIn('[data-test-input="dn"]', 'foo');
|
|
await fillIn('[data-test-input="username"]', 'bar');
|
|
await fillIn('[data-test-ttl-value="Rotation period"]', 5);
|
|
await click('[data-test-save]');
|
|
|
|
assert.ok(
|
|
this.transitionCalledWith('roles.role.details', 'static', 'test-role'),
|
|
'Transitions to role details route on save success'
|
|
);
|
|
});
|
|
|
|
test('it should save edited role with correct properties', async function (assert) {
|
|
assert.expect(2);
|
|
|
|
this.server.post('/ldap-test/static-role/:name', (schema, req) => {
|
|
const data = JSON.parse(req.requestBody);
|
|
const expected = { dn: 'foo', username: 'bar', rotation_period: '30s' };
|
|
assert.deepEqual(expected, data, 'POST request made to save role with correct properties');
|
|
});
|
|
|
|
this.model = this.store.peekRecord('ldap/role', 'static-role');
|
|
await this.renderComponent();
|
|
|
|
await fillIn('[data-test-input="name"]', 'test-role');
|
|
await fillIn('[data-test-input="dn"]', 'foo');
|
|
await fillIn('[data-test-input="username"]', 'bar');
|
|
await fillIn('[data-test-ttl-value="Rotation period"]', 30);
|
|
await click('[data-test-save]');
|
|
|
|
assert.ok(
|
|
this.transitionCalledWith('roles.role.details', 'static', 'test-role'),
|
|
'Transitions to role details route on save success'
|
|
);
|
|
});
|
|
});
|