Icu 10082 ldap account creation form (#1783)

* chore: 🤖 Add support for LDAP account creation
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2023-07-18 13:55:02 -07:00
1 parent 0a80ae3c9d
commit f5087ab4ee
3 files changed
+106

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ type:
help: The type of the resource, to help differentiate schemas
login_name:
label: Login Name
help: The account login name
username:
label: Username
set_password:
@@ -0,0 +1,84 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@showEditToggle={{if @model.isNew false true}}
as |form|
>
<InfoField @value={{@model.type}} disabled={{form.disabled}} as |F|>
<F.Label>{{t 'form.type.label'}}</F.Label>
</InfoField>
<Hds::Form::TextInput::Field
@isOptional={{true}}
name='name'
@value={{@model.name}}
@isInvalid={{@model.errors.name}}
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'name')}}
as |F|
>
<F.Label>{{t 'form.name.label'}}</F.Label>
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
{{#if @model.errors.name}}
<F.Error as |E|>
{{#each @model.errors.name as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::Textarea::Field
@isOptional={{true}}
@value={{@model.description}}
@isInvalid={{@model.errors.description}}
name='description'
disabled={{form.disabled}}
as |F|
>
<F.Label>{{t 'form.description.label'}}</F.Label>
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
{{#if @model.errors.description}}
<F.Error as |E|>
{{#each @model.errors.description as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
<Hds::Form::TextInput::Field
@isRequired={{true}}
name='login_name'
@value={{@model.login_name}}
@isInvalid={{@model.errors.login_name}}
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'login_name')}}
as |F|
>
<F.Label>{{t 'form.login_name.label'}}</F.Label>
<F.HelperText>{{t 'form.login_name.help'}}</F.HelperText>
{{#if @model.errors.login_name}}
<F.Error as |E|>
{{#each @model.errors.login_name as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
{{#if (can 'save model' @model)}}
<form.actions
@enableEditText={{t 'actions.edit-form'}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{/if}}
</Rose::Form>
@@ -85,6 +85,17 @@ module('Acceptance | accounts | create', function (hooks) {
assert.strictEqual(this.server.db.accounts.length, accountsCount + 1);
});
test('can create a new LDAP account', async function (assert) {
assert.expect(1);
const accountsCount = this.server.db.accounts.length;
await visit(urls.newAccount);
await fillIn('[name="name"]', 'Account name');
await fillIn('[name="description"]', 'description');
await fillIn('[name="login_name"]', 'username');
await click('form [type="submit"]:not(:disabled)');
assert.strictEqual(this.server.schema.accounts.all().models.length, accountsCount + 1);
});
test('Users cannot create a new account without proper authorization', async function (assert) {
assert.expect(2);
instances.authMethod.authorized_collection_actions.accounts = [];
@@ -130,6 +141,16 @@ module('Acceptance | accounts | create', function (hooks) {
assert.strictEqual(currentURL(), urls.accounts);
});
test('can cancel a new LDAP account creation', async function (assert) {
assert.expect(2);
const accountsCount = this.server.db.accounts.length;
await visit(urls.newAccount);
await fillIn('[name="name"]', 'Account name');
await click('form button:not([type="submit"])');
assert.strictEqual(this.server.db.accounts.length, accountsCount);
assert.strictEqual(currentURL(), urls.accounts);
});
test('saving a new account with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/accounts', () => {