web/admin: fix error when creating bindings due to hidden inputs (#5081)
* web/admin: fix error when creating bindings due to hidden inputs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix flaky test Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
95b99e3e55
commit
5c0d7f9a58
|
@ -59,7 +59,9 @@ class TestUserWriteStage(FlowTestCase):
|
||||||
user_qs = User.objects.filter(username=plan.context[PLAN_CONTEXT_PROMPT]["username"])
|
user_qs = User.objects.filter(username=plan.context[PLAN_CONTEXT_PROMPT]["username"])
|
||||||
self.assertTrue(user_qs.exists())
|
self.assertTrue(user_qs.exists())
|
||||||
self.assertTrue(user_qs.first().check_password(password))
|
self.assertTrue(user_qs.first().check_password(password))
|
||||||
self.assertEqual(list(user_qs.first().ak_groups.all()), [self.group, self.other_group])
|
self.assertEqual(
|
||||||
|
list(user_qs.first().ak_groups.order_by("name")), [self.other_group, self.group]
|
||||||
|
)
|
||||||
self.assertEqual(user_qs.first().attributes, {USER_ATTRIBUTE_SOURCES: [self.source.name]})
|
self.assertEqual(user_qs.first().attributes, {USER_ATTRIBUTE_SOURCES: [self.source.name]})
|
||||||
|
|
||||||
def test_user_update(self):
|
def test_user_update(self):
|
||||||
|
|
|
@ -10,7 +10,6 @@ import { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { TemplateResult, html } from "lit";
|
import { TemplateResult, html } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators.js";
|
import { customElement, property, state } from "lit/decorators.js";
|
||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Flow,
|
Flow,
|
||||||
|
@ -48,19 +47,21 @@ export class StageBindingForm extends ModelForm<FlowStageBinding, string> {
|
||||||
return t`Successfully created binding.`;
|
return t`Successfully created binding.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
send(data: FlowStageBinding): Promise<unknown> {
|
||||||
send = (data: FlowStageBinding): Promise<FlowStageBinding> => {
|
|
||||||
if (this.instance?.pk) {
|
if (this.instance?.pk) {
|
||||||
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsUpdate({
|
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsUpdate({
|
||||||
fsbUuid: this.instance.pk,
|
fsbUuid: this.instance.pk,
|
||||||
flowStageBindingRequest: data,
|
flowStageBindingRequest: data,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (this.targetPk) {
|
||||||
|
data.target = this.targetPk;
|
||||||
|
}
|
||||||
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsCreate({
|
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsCreate({
|
||||||
flowStageBindingRequest: data,
|
flowStageBindingRequest: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
async getOrder(): Promise<number> {
|
async getOrder(): Promise<number> {
|
||||||
if (this.instance?.pk) {
|
if (this.instance?.pk) {
|
||||||
|
@ -78,14 +79,7 @@ export class StageBindingForm extends ModelForm<FlowStageBinding, string> {
|
||||||
|
|
||||||
renderTarget(): TemplateResult {
|
renderTarget(): TemplateResult {
|
||||||
if (this.instance?.target || this.targetPk) {
|
if (this.instance?.target || this.targetPk) {
|
||||||
return html`
|
return html``;
|
||||||
<input
|
|
||||||
required
|
|
||||||
name="target"
|
|
||||||
type="hidden"
|
|
||||||
value=${ifDefined(this.instance?.target || this.targetPk)}
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
return html`<ak-form-element-horizontal label=${t`Target`} ?required=${true} name="target">
|
return html`<ak-form-element-horizontal label=${t`Target`} ?required=${true} name="target">
|
||||||
<ak-search-select
|
<ak-search-select
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { t } from "@lingui/macro";
|
||||||
import { CSSResult, css } from "lit";
|
import { CSSResult, css } from "lit";
|
||||||
import { TemplateResult, html } from "lit";
|
import { TemplateResult, html } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators.js";
|
import { customElement, property, state } from "lit/decorators.js";
|
||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
|
||||||
|
|
||||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
||||||
import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css";
|
import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css";
|
||||||
|
@ -83,7 +82,10 @@ export class PolicyBindingForm extends ModelForm<PolicyBinding, string> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: PolicyBinding): Promise<PolicyBinding> => {
|
send(data: PolicyBinding): Promise<unknown> {
|
||||||
|
if (this.targetPk) {
|
||||||
|
data.target = this.targetPk;
|
||||||
|
}
|
||||||
if (this.instance?.pk) {
|
if (this.instance?.pk) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsUpdate({
|
||||||
policyBindingUuid: this.instance.pk,
|
policyBindingUuid: this.instance.pk,
|
||||||
|
@ -94,7 +96,7 @@ export class PolicyBindingForm extends ModelForm<PolicyBinding, string> {
|
||||||
policyBindingRequest: data,
|
policyBindingRequest: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
async getOrder(): Promise<number> {
|
async getOrder(): Promise<number> {
|
||||||
if (this.instance?.pk) {
|
if (this.instance?.pk) {
|
||||||
|
@ -270,12 +272,6 @@ export class PolicyBindingForm extends ModelForm<PolicyBinding, string> {
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input
|
|
||||||
required
|
|
||||||
name="target"
|
|
||||||
type="hidden"
|
|
||||||
value=${ifDefined(this.instance?.target || this.targetPk)}
|
|
||||||
/>
|
|
||||||
<ak-form-element-horizontal name="enabled">
|
<ak-form-element-horizontal name="enabled">
|
||||||
<label class="pf-c-switch">
|
<label class="pf-c-switch">
|
||||||
<input
|
<input
|
||||||
|
|
Reference in a new issue