Skip to content

Commit

Permalink
SHIBUI-1931 Fixed assertion consumer services
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 9, 2021
1 parent 1297da3 commit e70257f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ message.delete-attribute-title=Delete Attribute?
message.delete-attribute-body=You are requesting to delete a custom attribute. If you complete this process the attribute will be removed. This cannot be undone. Do you wish to continue?

message.must-be-unique=Must be unique.
message.must-be-number=Must be a number.
message.name-must-be-unique=Name must be unique.
message.uri-valid-format=URI must be valid format.
message.id-unique=ID must be unique.
Expand Down
3 changes: 0 additions & 3 deletions ui/src/app/form/component/widgets/RadioWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ const RadioWidget = ({

const inline = Boolean(options && options.inline);


console.log(enumOptions, id);

return (
<Form.Group className="mb-0">
<Form.Label className="d-block">
Expand Down
37 changes: 23 additions & 14 deletions ui/src/app/metadata/domain/source/SourceDefinition.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defaults } from 'lodash';
import { defaults, merge, toNumber, uniq } from 'lodash';
import defaultsDeep from 'lodash/defaultsDeep';
import API_BASE_PATH from '../../../App.constant';
import {removeNull} from '../../../core/utility/remove_null';

import { updatedDiff, detailedDiff } from 'deep-object-diff';

export const SourceBase = {
label: 'Metadata Source',
Expand All @@ -26,18 +26,6 @@ export const SourceBase = {
if (entityIds.indexOf(formData.entityId) > -1) {
errors.entityId.addError('message.id-unique');
}

/*if (!formData?.relyingPartyOverrides?.signAssertion && formData?.relyingPartyOverrides?.dontSignResponse) {
errors = {
...errors,
relyingPartyOverrides: {
dontSignResponse: {
__errors: ['message.invalid-signing'],
nonBlocking: true
}
}
};
}*/
return errors;
}
},
Expand All @@ -56,6 +44,27 @@ export const SourceBase = {
return warnings;
},

bindings: (original, formData) => {

let d = { ...formData };

if (formData.assertionConsumerServices && formData.assertionConsumerServices.length) {
const { updated, added } = detailedDiff(original.assertionConsumerServices, formData.assertionConsumerServices);
const merged = merge(updated, added);
const changingDefault = Object.keys(merged).some(k => merged[k].hasOwnProperty('makeDefault'));
if (changingDefault) {
const settingToTrue = Object.keys(merged).some(k => merged[k].makeDefault === true);
if (settingToTrue) {
d.assertionConsumerServices = d.assertionConsumerServices.map((s, i) => ({
...s,
makeDefault: i === toNumber(Object.keys(merged)[0])
}));
}
}
}
return d;
},

uiSchema: {
'ui:order': ['serviceProviderName', '*'],
layout: {
Expand Down
11 changes: 9 additions & 2 deletions ui/src/app/metadata/editor/MetadataEditorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { templates } from '../../form/component';
import { useUiSchema } from '../hooks/schema';
import Alert from 'react-bootstrap/Alert';

import { updatedDiff } from 'deep-object-diff';

const invisErrors = ['const', 'oneOf']

function ErrorListTemplate () {
Expand All @@ -29,6 +31,11 @@ export function MetadataEditorForm({ metadata, definition, schema, current, onCh
const transformErrors = (errors) => {
return errors.filter(e => invisErrors.indexOf(e.name) === -1);
}

const onFormChange = (form) => {
onChange(definition.bindings ? { ...form, formData: definition.bindings(data, form.formData) }: form);
};

return (
<>
{step.locked && <div className="">
Expand All @@ -49,8 +56,8 @@ export function MetadataEditorForm({ metadata, definition, schema, current, onCh
</div>}
<div className="container-fluid">
<Form formData={data}
noHtml5Validate={true}
onChange={(form) => onChange(form)}
noHtml5Validate={false}
onChange={(form) => onFormChange(form)}
onSubmit={() => onSubmit()}
schema={schema}
uiSchema={uiSchema}
Expand Down

0 comments on commit e70257f

Please sign in to comment.