vault/ui/tests/integration/components/ldap/page/configuration-test.js
claire bontempo 4ac07e1d97
UI: HDS adoption replace <ConfirmAction> component (#21520)
* replace confirm-action dropdown with button+modal

* add modal frame to sidebar

* fix weird paragraph indent

* pass button text as arg

* add warning color to rotate modals

* update seal action and config ssh

* cleanup confirm action

* edit form

* add dropdown arg

* put back seal text

* put back confirm button text

* fix toolbar stylinggp

* popup member group

* move up title

* finish popup- components

* keymgmt

* fix modal button logic

* remaining app template components

* add period for angel

* vault cluster items

* add button text assertion

* remaining instances

* remove arg for passing confirm text

* contextual confirm action components

* delete old components

* update docs

* ammend dropdown loading states, add getter for confirm button color

* address feedback

* remove @disabled arg and add @disabledMessage

* add changelog;

* mfa tests

* update test selectors

* lol cleanup selectors

* start confirm action tests WIP

* move dropdown class directly to component

* add default color of isInDropdown

* final cleanup

* add tests

* remove @buttonColor as arg for dropdown

* update confirm action tests

* updae modals with disabled message

* refactor provider edit test
2023-11-17 23:44:21 +00:00

114 lines
4.3 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 } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { duration } from 'core/helpers/format-duration';
import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap';
const selectors = {
rotateAction: '[data-test-toolbar-rotate-action]',
confirmRotate: '[data-test-confirm-button]',
configAction: '[data-test-toolbar-config-action]',
configCta: '[data-test-config-cta]',
mountConfig: '[data-test-mount-config]',
pageError: '[data-test-page-error]',
fieldValue: (label) => `[data-test-value-div="${label}"]`,
};
module('Integration | Component | ldap | Page::Configuration', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'ldap');
setupMirage(hooks);
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.backend = createSecretsEngine(this.store);
this.breadcrumbs = generateBreadcrumbs(this.backend.id);
this.store.pushPayload('ldap/config', {
modelName: 'ldap/config',
backend: 'ldap-test',
...this.server.create('ldap-config'),
});
this.config = this.store.peekRecord('ldap/config', 'ldap-test');
this.renderComponent = () => {
return render(
hbs`<Page::Configuration
@backendModel={{this.backend}}
@configModel={{this.config}}
@configError={{this.error}}
@breadcrumbs={{this.breadcrumbs}}
/>`,
{
owner: this.engine,
}
);
};
});
test('it should render tab page header, config cta and mount config', async function (assert) {
this.config = null;
await this.renderComponent();
assert.dom('.title svg').hasClass('flight-icon-folder-users', 'LDAP icon renders in title');
assert.dom('.title').hasText('ldap-test', 'Mount path renders in title');
assert
.dom(selectors.rotateAction)
.doesNotExist('Rotate root action is hidden when engine is not configured');
assert.dom(selectors.configAction).hasText('Configure LDAP', 'Toolbar action has correct text');
assert.dom(selectors.configCta).exists('Config cta renders');
assert.dom(selectors.mountConfig).exists('Mount config renders');
});
test('it should render config fetch error', async function (assert) {
this.config = null;
this.error = { httpStatus: 403, message: 'Permission denied' };
await this.renderComponent();
assert.dom(selectors.pageError).exists('Config fetch error is rendered');
});
test('it should render display fields', async function (assert) {
await this.renderComponent();
assert.dom(selectors.fieldValue('Administrator Distinguished Name')).hasText(this.config.binddn);
assert.dom(selectors.fieldValue('URL')).hasText(this.config.url);
assert.dom(selectors.fieldValue('Schema')).hasText(this.config.schema);
assert.dom(selectors.fieldValue('Password Policy')).hasText(this.config.password_policy);
assert.dom(selectors.fieldValue('Userdn')).hasText(this.config.userdn);
assert.dom(selectors.fieldValue('Userattr')).hasText(this.config.userattr);
assert
.dom(selectors.fieldValue('Connection Timeout'))
.hasText(duration([this.config.connection_timeout]));
assert.dom(selectors.fieldValue('Request Timeout')).hasText(duration([this.config.request_timeout]));
assert.dom(selectors.fieldValue('CA Certificate')).hasText(this.config.certificate);
assert.dom(selectors.fieldValue('Start TLS')).includesText('No');
assert.dom(selectors.fieldValue('Insecure TLS')).includesText('No');
assert.dom(selectors.fieldValue('Client TLS Certificate')).hasText(this.config.client_tls_cert);
assert.dom(selectors.fieldValue('Client TLS Key')).hasText(this.config.client_tls_key);
});
test('it should rotate root password', async function (assert) {
assert.expect(1);
this.server.post(`/${this.config.backend}/rotate-root`, () => {
assert.ok(true, 'Request made to rotate root password');
});
await this.renderComponent();
await click(selectors.rotateAction);
await click(selectors.confirmRotate);
});
});