diff --git a/ui/package.json b/ui/package.json index 728b8a0f6..41021eba3 100644 --- a/ui/package.json +++ b/ui/package.json @@ -79,6 +79,24 @@ "lines": 80, "statements": 80 }, + "./src/app/metadata/domain/filter/component/": { + "branches": 0, + "functions": 0, + "lines": 0, + "statements": 0 + }, + "./src/app/metadata/domain/source/component/": { + "branches": 0, + "functions": 0, + "lines": 0, + "statements": 0 + }, + "./src/app/metadata/domain/provider/component/": { + "branches": 0, + "functions": 0, + "lines": 0, + "statements": 0 + }, "./src/app/metadata/hooks/": { "branches": 80, "functions": 80, diff --git a/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js b/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js index d04cfab6e..1216e4a62 100644 --- a/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js +++ b/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js @@ -49,7 +49,7 @@ export const CustomAttributeDefinition = { return data; } const { attributeType } = data; - let parsed = { ...data }; + let { defaultValueBoolean, defaultValueString, ...parsed } = data; if (attributeType === 'SELECTION_LIST') { parsed = { ...parsed, @@ -61,14 +61,14 @@ export const CustomAttributeDefinition = { if (attributeType === 'BOOLEAN') { parsed = { ...parsed, - defaultValue: data.defaultValueBoolean + defaultValue: defaultValueBoolean } } if (attributeType === 'STRING') { parsed = { ...parsed, - defaultValue: data.defaultValueString + defaultValue: defaultValueString } } @@ -79,7 +79,7 @@ export const CustomAttributeDefinition = { if (!changes) { return changes; } - let formatted = { ...changes }; + let { defaultValue, ...formatted } = changes; const { attributeType } = changes; if (attributeType === 'SELECTION_LIST') { @@ -87,7 +87,7 @@ export const CustomAttributeDefinition = { ...formatted, customAttrListDefinitions: formatted.customAttrListDefinitions.map(d => ({ value: d, - default: d === changes.defaultValue + default: d === defaultValue })) } } @@ -95,14 +95,14 @@ export const CustomAttributeDefinition = { if (attributeType === 'BOOLEAN') { formatted = { ...formatted, - defaultValueBoolean: formatted.defaultValue === 'true' ? true : false + defaultValueBoolean: defaultValue === 'true' ? true : false } } if (attributeType === 'STRING') { formatted = { ...formatted, - defaultValueString: formatted.defaultValue + defaultValueString: defaultValue } } diff --git a/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.test.js b/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.test.js new file mode 100644 index 000000000..9fbbe6e6c --- /dev/null +++ b/ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.test.js @@ -0,0 +1,81 @@ +import { CustomAttributeDefinition } from "./CustomAttributeDefinition"; + + +describe('formatter', () => { + it('should format the object passed for the json-schema-form', () => { + expect(CustomAttributeDefinition.formatter(null)).toBeNull(); + + expect(CustomAttributeDefinition.formatter({ + helpText: 'foo', + attributeType: 'SELECTION_LIST', + customAttrListDefinitions: [ + 'foo' + ], + defaultValue: 'foo' + })).toEqual({ + helpText: 'foo', + attributeType: 'SELECTION_LIST', + customAttrListDefinitions: [ + { + default: true, + value: 'foo' + } + ] + }); + + expect(CustomAttributeDefinition.formatter({ + attributeType: 'BOOLEAN', + defaultValue: 'true' + })).toEqual({ + attributeType: 'BOOLEAN', + defaultValueBoolean: true + }); + + expect(CustomAttributeDefinition.formatter({ + attributeType: 'STRING', + defaultValue: 'true' + })).toEqual({ + attributeType: 'STRING', + defaultValueString: 'true' + }); + }); +}); + +describe('parser', () => { + + it('should parse the object provided to save to the server', () => { + expect(CustomAttributeDefinition.parser(null)).toBeNull(); + + expect(CustomAttributeDefinition.parser({ + attributeType: 'SELECTION_LIST', + customAttrListDefinitions: [ + { + default: true, + value: 'foo' + } + ] + })).toEqual({ + attributeType: 'SELECTION_LIST', + customAttrListDefinitions: [ + 'foo' + ], + defaultValue: 'foo' + }); + + expect(CustomAttributeDefinition.parser({ + attributeType: 'BOOLEAN', + defaultValueBoolean: true + })).toEqual({ + attributeType: 'BOOLEAN', + defaultValue: true + }); + + expect(CustomAttributeDefinition.parser({ + attributeType: 'STRING', + defaultValueString: 'true' + })).toEqual({ + attributeType: 'STRING', + defaultValue: 'true' + }); + }); +}); \ No newline at end of file diff --git a/ui/src/app/metadata/domain/filter/BaseFilterDefinition.test.js b/ui/src/app/metadata/domain/filter/BaseFilterDefinition.test.js new file mode 100644 index 000000000..0f507c817 --- /dev/null +++ b/ui/src/app/metadata/domain/filter/BaseFilterDefinition.test.js @@ -0,0 +1,19 @@ +import { BaseFilterDefinition } from "./BaseFilterDefinition"; + +describe('formatter', () => { + it('should return the provided object with no changes', () => { + expect(BaseFilterDefinition.formatter({})).toEqual({}); + }) +}); + +describe('parser', () => { + it('should return the provided object with no changes', () => { + expect(BaseFilterDefinition.parser({})).toEqual({}); + }) +}); + +describe('display', () => { + it('should return the provided object with no changes', () => { + expect(BaseFilterDefinition.display({})).toEqual({}); + }) +}); \ No newline at end of file diff --git a/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.js b/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.js index 727df9f8f..505eac237 100644 --- a/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.js +++ b/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.js @@ -59,10 +59,10 @@ export const EntityAttributesFilterWizard = { warnings: (data) => { let warnings = {}; if (!data?.relyingPartyOverrides?.signAssertion && data?.relyingPartyOverrides?.dontSignResponse) { + // ...(warnings.hasOwnProperty('options') ? warnings['options'] : []), warnings = { ...warnings, 'options': [ - ...(warnings.hasOwnProperty('options') ? warnings['options'] : []), 'message.invalid-signing' ] }; @@ -72,7 +72,7 @@ export const EntityAttributesFilterWizard = { parser: (changes) => { return { ...changes, - relyingPartyOverrides: removeNull(changes) + relyingPartyOverrides: removeNull(changes.relyingPartyOverrides) }; }, formatter: (changes) => ({ diff --git a/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.test.js b/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.test.js new file mode 100644 index 000000000..e0450ec9b --- /dev/null +++ b/ui/src/app/metadata/domain/filter/EntityAttributesFilterDefinition.test.js @@ -0,0 +1,124 @@ +import { EntityAttributesFilterWizard } from "./EntityAttributesFilterDefinition"; +const addErrorMockFn = jest.fn(); + +const filters = [ + { + resourceId: 1, + name: 'foo' + }, + { + resourceId: 2, + name: 'baz' + } +]; + +const e = { + name: { addError: addErrorMockFn }, + entityAttributesFilterTarget: { + addError: addErrorMockFn, + entityAttributesFilterTargetType: { + addError: addErrorMockFn + }, + value: { + addError: addErrorMockFn + } + } +}; + +describe('validator function', () => { + it('should validate against the provider names', () => { + const validator = EntityAttributesFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'foo' + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(1); + }); + + it('should validate against the provider names 2', () => { + const validator = EntityAttributesFilterWizard.validator(filters); + const errors = validator({ + name: 'bar' + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(0); + }); + + it('should validate the regex target', () => { + const validator = EntityAttributesFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'baz2', + entityAttributesFilterTarget: { + entityAttributesFilterTargetType: 'REGEX', + value: '()((*()*)(**' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(1); + }); + + it('should validate the regex target 2', () => { + const validator = EntityAttributesFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'baz2', + entityAttributesFilterTarget: { + entityAttributesFilterTargetType: 'REGEX', + value: 'test' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(0); + }); +}); + +describe('formatter', () => { + it('should return the provided object with no changes', () => { + expect(EntityAttributesFilterWizard.formatter({})).toEqual({ '@type': 'EntityAttributes' }); + }) +}); + +describe('parser', () => { + it('should return the provided object with no changes', () => { + expect(EntityAttributesFilterWizard.parser({})).toEqual({ + relyingPartyOverrides: {} + }); + + expect(EntityAttributesFilterWizard.parser({ + relyingPartyOverrides: { + foo: null + } + })).toEqual({ + relyingPartyOverrides: {} + }); + }) +}); + +describe('warnings', () => { + it('should return warnings based on provided data', () => { + expect(EntityAttributesFilterWizard.warnings({ + relyingPartyOverrides: { + signAssertion: false, + dontSignResponse: true + } + })).toEqual({ + 'options': [ + 'message.invalid-signing' + ] + }); + }) + + it('should return no warnings', () => { + expect(EntityAttributesFilterWizard.warnings({ + relyingPartyOverrides: { + signAssertion: true, + dontSignResponse: true + } + })).toEqual({}); + }) +}); + +describe('display', () => { + it('should return the provided object with no changes', () => { + expect(EntityAttributesFilterWizard.display({})).toEqual({}); + }) +}); \ No newline at end of file diff --git a/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js index ff16383e9..ecbc8a7ea 100644 --- a/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js +++ b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.js @@ -27,7 +27,7 @@ export const NameIDFilterWizard = { validator: (data = [], current = { resourceId: null }) => { const filters = current ? data.filter(s => s.resourceId !== current.resourceId) : data; - const names = filters.map(s => s.entityId); + const names = filters.map(s => s.name); return (formData, errors) => { if (names.indexOf(formData.name) > -1) { diff --git a/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.test.js b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.test.js new file mode 100644 index 000000000..b2500cfc3 --- /dev/null +++ b/ui/src/app/metadata/domain/filter/NameIdFilterDefinition.test.js @@ -0,0 +1,78 @@ +import { NameIDFilterWizard } from "./NameIdFilterDefinition"; +const addErrorMockFn = jest.fn(); + +const filters = [ + { + resourceId: 1, + name: 'foo' + }, + { + resourceId: 2, + name: 'baz' + } +]; + +const e = { + name: { addError: addErrorMockFn }, + nameIdFormatFilterTarget: { + addError: addErrorMockFn, + nameIdFormatFilterTargetType: { + addError: addErrorMockFn + }, + value: { + addError: addErrorMockFn + } + } +}; + +describe('validator function', () => { + it('should validate against the provider names', () => { + const validator = NameIDFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'foo' + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(1); + }); + + it('should validate against the provider names 2', () => { + const validator = NameIDFilterWizard.validator(filters); + const errors = validator({ + name: 'bar' + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(0); + }); + + it('should validate the regex target', () => { + const validator = NameIDFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'baz2', + nameIdFormatFilterTarget: { + nameIdFormatFilterTargetType: 'REGEX', + value: '()((*()*)(**' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(1); + }); + + it('should validate the regex target 2', () => { + const validator = NameIDFilterWizard.validator(filters, 2); + const errors = validator({ + name: 'baz2', + nameIdFormatFilterTarget: { + nameIdFormatFilterTargetType: 'REGEX', + value: 'test' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(0); + }); +}); + +describe('formatter', () => { + it('should return the provided object with no changes', () => { + expect(NameIDFilterWizard.formatter({})).toEqual({ '@type': 'NameIDFormat' }); + }) +}); diff --git a/ui/src/app/metadata/domain/provider/DynamicHttpMetadataProviderDefinition.test.js b/ui/src/app/metadata/domain/provider/DynamicHttpMetadataProviderDefinition.test.js new file mode 100644 index 000000000..35e71244d --- /dev/null +++ b/ui/src/app/metadata/domain/provider/DynamicHttpMetadataProviderDefinition.test.js @@ -0,0 +1,57 @@ +import { DynamicHttpMetadataProviderWizard } from './DynamicHttpMetadataProviderDefinition'; +import schema from '../../../../testing/dynamic-http.schema'; +const addErrorMockFn = jest.fn(); + +const providers = [ + { + resourceId: 1, + name: 'foo', + xmlId: 'bar' + }, + { + resourceId: 2, + name: 'baz', + xmlId: 'xmlId' + } +]; + +const e = { + name: { addError: addErrorMockFn }, + metadataRequestURLConstructionScheme: { + addError: addErrorMockFn, + '@type': { + addError: addErrorMockFn + }, + match: { + addError: addErrorMockFn + } + } +}; + +describe('validator function', () => { + it('should NOT add an error if the regex provided is valid', () => { + const validator = DynamicHttpMetadataProviderWizard.validator(providers); + const errors = validator({ + name: 'baz text', + metadataRequestURLConstructionScheme: { + '@type': 'Regex', + match: 'foo' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(0); + }); + + it('should add an error if the regex provided is not valid', () => { + const validator = DynamicHttpMetadataProviderWizard.validator(providers); + const errors = validator({ + name: 'baz test', + metadataRequestURLConstructionScheme: { + '@type': 'Regex', + match: '*(*&^))' + } + }, e); + + expect(addErrorMockFn).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ui/src/app/metadata/domain/provider/utility/providerFilterProcessor.test.js b/ui/src/app/metadata/domain/provider/utility/providerFilterProcessor.test.js new file mode 100644 index 000000000..e2b448dfe --- /dev/null +++ b/ui/src/app/metadata/domain/provider/utility/providerFilterProcessor.test.js @@ -0,0 +1,37 @@ +import { metadataFilterProcessor } from './providerFilterProcessor'; + +describe('provider model utilities', () => { + describe('metadata filter processor function', () => { + it('should return null if no schema provided', () => { + expect(metadataFilterProcessor(null)).toBe(null); + }); + + it('should return the schema if no properties are detected', () => { + const schema = {}; + expect(metadataFilterProcessor(schema)).toBe(schema); + }); + + it('should return the schema if no metadataFilters property exists in the schema', () => { + const schema = { properties: { foo: 'bar' } }; + expect(metadataFilterProcessor(schema)).toBe(schema); + }); + + it('should turn the filters into an object if provided', () => { + const schema = { + properties: { + metadataFilters: { + type: 'array', + items: [ + { + $id: 'foo', + type: 'string' + } + ] + } + } + }; + const processed = metadataFilterProcessor(schema); + expect(processed.properties.metadataFilters.properties.foo.type).toBe('string'); + }); + }); +}); diff --git a/ui/src/app/metadata/domain/source/SourceDefinition.test.js b/ui/src/app/metadata/domain/source/SourceDefinition.test.js index 130cb1110..98001cf0b 100644 --- a/ui/src/app/metadata/domain/source/SourceDefinition.test.js +++ b/ui/src/app/metadata/domain/source/SourceDefinition.test.js @@ -11,5 +11,104 @@ describe('SourceDefinition', () => { } })).toEqual({bar: 'baz'}); }); - }) + }); + + describe('warnings', () => { + it('should return warnings based on provided data', () => { + expect(SourceBase.warnings({ + relyingPartyOverrides: { + signAssertion: false, + dontSignResponse: true + } + })).toEqual({ + 'relying-party': [ + 'message.invalid-signing' + ] + }); + }) + + it('should return no warnings', () => { + expect(SourceBase.warnings({ + relyingPartyOverrides: { + signAssertion: true, + dontSignResponse: true + } + })).toEqual({}); + }) + }); + + describe('bindings', () => { + it('should allow one assertion consumer service to be default', () => { + expect(SourceBase.bindings( + { + assertionConsumerServices: [ + { + makeDefault: false + }, + { + makeDefault: true + } + ] + }, + { + assertionConsumerServices: [ + { + makeDefault: true + }, + { + makeDefault: true + } + ] + } + )).toEqual({ + assertionConsumerServices: [ + { + makeDefault: true + }, + { + makeDefault: false + } + ] + }); + }) + + it('should set x509Certificates available', () => { + expect(SourceBase.bindings( + {}, + { + securityInfo: { + x509Certificates: [ + {} + ] + } + } + )).toMatchObject({ + securityInfo: { + x509Certificates: [ + {} + ], + x509CertificateAvailable: true + } + }); + + expect(SourceBase.bindings( + {}, + { + securityInfo: { + x509Certificates: [] + } + } + )).toMatchObject({ + securityInfo: { + x509Certificates: [], + x509CertificateAvailable: false + } + }); + + expect(SourceBase.bindings( + {}, + {} + )).toEqual({}); + }); + }); }); \ No newline at end of file diff --git a/ui/src/app/metadata/domain/transform.test.js b/ui/src/app/metadata/domain/transform.test.js new file mode 100644 index 000000000..1ae2c8fa7 --- /dev/null +++ b/ui/src/app/metadata/domain/transform.test.js @@ -0,0 +1,19 @@ +import { transformErrors } from './transform'; + +const errors = [ + {name: 'const'}, + {name: 'oneOf'}, + {name: 'pattern', property: '/email'}, + {name: 'pattern', property: 'foo'}, + {name: 'type', message: 'bar'}, + {name: 'type', message: 'should be string'} +]; + +it('should transform error messages', () => { + expect(transformErrors(errors)).toEqual([ + { name: 'pattern', property: '/email', message: 'message.valid-email' }, + { name: 'pattern', property: 'foo', message: 'message.valid-duration' }, + { name: 'type', message: 'bar' }, + { name: 'type', message: 'message.required' } + ]); +}); \ No newline at end of file diff --git a/ui/src/app/metadata/hooks/configuration.js b/ui/src/app/metadata/hooks/configuration.js index dc23b874f..0574359a1 100644 --- a/ui/src/app/metadata/hooks/configuration.js +++ b/ui/src/app/metadata/hooks/configuration.js @@ -1,4 +1,4 @@ -import { getConfigurationSections, getLimitedPropertiesFn } from './schema'; +import { getConfigurationSections, getLimitedProperties } from './schema'; export const getLimitedConfigurationsFn = (configurations, limited) => { return configurations ? ({ @@ -6,7 +6,7 @@ export const getLimitedConfigurationsFn = (configurations, limited) => { sections: !limited ? configurations.sections : configurations.sections.map(s => ({ ...s, - properties: getLimitedPropertiesFn(s.properties), + properties: getLimitedProperties(s.properties), })) }) : configurations; }; diff --git a/ui/src/app/metadata/hooks/configuration.test.js b/ui/src/app/metadata/hooks/configuration.test.js new file mode 100644 index 000000000..e69de29bb diff --git a/ui/src/app/metadata/hooks/utility.js b/ui/src/app/metadata/hooks/utility.js index 653448c25..05546fd8a 100644 --- a/ui/src/app/metadata/hooks/utility.js +++ b/ui/src/app/metadata/hooks/utility.js @@ -170,14 +170,14 @@ export const assignValueToProperties = (models, properties, definition, schema) }); }; -export const getLimitedPropertiesFn = (properties) => { +export const getLimitedProperties = (properties) => { return ([ ...properties .filter(p => p.differences) .map(p => { const parsed = { ...p }; if (p.properties) { - parsed.properties = getLimitedPropertiesFn(p.properties); + parsed.properties = getLimitedProperties(p.properties); } return parsed; }) diff --git a/ui/src/app/metadata/hooks/utility.test.js b/ui/src/app/metadata/hooks/utility.test.js index 9faaebec2..36a10d688 100644 --- a/ui/src/app/metadata/hooks/utility.test.js +++ b/ui/src/app/metadata/hooks/utility.test.js @@ -1,6 +1,18 @@ -import { getStepProperties, getDefinition, getPropertyItemSchema, getStepProperty } from './utility'; import SCHEMA from '../../../testing/simpleSchema'; +import { + getConfigurationSections, + getLimitedProperties, + assignValueToProperties, + getStepProperties, + getDefinition, + getPropertyItemSchema, + getStepProperty +} from './utility'; + +import { SCHEMA as formSchema } from '../../../testing/form-schema'; +import { MockMetadataWizard } from '../../../testing/mockMetadataWizard'; + describe('domain utility functions', () => { describe('getStepProperties function', () => { it('should return an empty array of schema or schema.properties is not defined', () => { @@ -57,5 +69,118 @@ describe('domain utility functions', () => { expect(property.type).toBe('string'); }); }); + + describe('config reducer utilities', () => { + + const model = { + name: 'foo', + serviceEnabled: true, + foo: { + bar: 'bar', + baz: 'baz' + }, + list: [ + 'super', + 'cool' + ] + }; + + const props = [ + { + id: 'name', + items: null, + name: 'label.metadata-provider-name-dashboard-display-only', + properties: [], + type: 'string', + value: null, + widget: { id: 'string', help: 'message.must-be-unique' } + }, + { + id: 'serviceEnabled', + items: null, + name: 'serviceEnabled', + properties: [], + type: 'string', + value: null, + widget: { id: 'select', disabled: true } + }, + { + id: 'foo', + items: null, + name: 'foo', + type: 'object', + properties: [ + { + id: 'bar', + name: 'bar', + type: 'string', + properties: [] + }, + { + id: 'baz', + name: 'baz', + type: 'string', + properties: [] + } + ] + }, + { + id: 'list', + name: 'list', + type: 'array', + items: { + type: 'string' + }, + widget: { + id: 'datalist', + data: [ + { key: 'super', label: 'super' }, + { key: 'cool', label: 'cool' }, + { key: 'notcool', label: 'notcool' } + ] + } + } + ]; + + const definition = MockMetadataWizard; + + describe('assignValueToProperties function', () => { + it('should assign appropriate values to the given schema properties', () => { + const assigned = assignValueToProperties([model], props, definition); + expect(assigned[0].value).toEqual(['foo']); + expect(assigned[1].value).toEqual([true]); + }); + + it('should assign differences when passed multiple models', () => { + const assigned = assignValueToProperties([model, { + ...model, + name: 'bar', + list: [ + 'super', + 'notcool' + ] + }], props, definition); + expect(assigned[0].differences).toBe(true); + }); + }); + + describe('getLimitedPropertiesFn function', () => { + it('should filter properties without differences', () => { + const assigned = assignValueToProperties([model, { + ...model, + name: 'bar' + }], props, definition); + expect(getLimitedProperties(assigned).length).toBe(1); + }); + }); + + describe('getConfigurationSections', () => { + it('should parse the schema, definition, and model into a MetadataConfiguration', () => { + const config = getConfigurationSections([model], definition, formSchema); + expect(config.sections).toBeDefined(); + }); + }); + }); + }); diff --git a/ui/src/testing/form-schema.js b/ui/src/testing/form-schema.js new file mode 100644 index 000000000..01654b15a --- /dev/null +++ b/ui/src/testing/form-schema.js @@ -0,0 +1,129 @@ +export const SCHEMA = { + 'title': 'MetadataResolver', + 'type': 'object', + 'widget': { + 'id': 'fieldset' + }, + 'properties': { + 'name': { + 'title': 'Metadata Provider Name (Dashboard Display Only)', + 'description': 'Metadata Provider Name (Dashboard Display Only)', + 'type': 'string', + 'widget': { + 'id': 'string', + 'help': 'Must be unique.' + } + }, + '@type': { + 'title': 'Metadata Provider Type', + 'description': 'Metadata Provider Type', + 'ui:placeholder': 'Select a metadata provider type', + 'type': 'string', + 'widget': { + 'id': 'select' + }, + 'oneOf': [ + { + 'enum': [ + 'FileBackedHttpMetadataResolver' + ], + 'description': 'FileBackedHttpMetadataProvider' + } + ] + }, + 'list': { + 'title': 'label.retained-roles', + 'description': 'tooltip.retained-roles', + 'type': 'array', + 'items': { + 'widget': { + 'id': 'select' + }, + 'type': 'string', + 'oneOf': [ + { + 'enum': [ + 'SPSSODescriptor' + ], + 'description': 'value.spdescriptor' + }, + { + 'enum': [ + 'AttributeAuthorityDescriptor' + ], + 'description': 'value.attr-auth-descriptor' + } + ] + } + }, + 'formatFilterTarget': { + 'title': 'label.search-criteria', + 'description': 'tooltip.search-criteria', + 'type': 'object', + 'widget': { + 'id': 'filter-target', + 'target': 'formatFilterTargetType' + }, + 'properties': { + 'formatFilterTargetType': { + 'title': '', + 'type': 'string', + 'default': 'ENTITY', + 'oneOf': [ + { + 'enum': [ + 'ENTITY' + ], + 'description': 'value.entity-id' + }, + { + 'enum': [ + 'REGEX' + ], + 'description': 'value.regex' + }, + { + 'enum': [ + 'CONDITION_SCRIPT' + ], + 'description': 'value.script' + } + ] + }, + 'value': { + 'type': 'array', + 'minItems': 1, + 'uniqueItems': true, + 'items': { + 'type': 'string' + } + } + }, + 'required': [ + 'value', + 'nameIdFormatFilterTargetType' + ] + } + }, + 'required': [ + 'name', + '@type' + ], + 'fieldsets': [ + { + 'type': 'section', + 'fields': [ + 'name', + '@type' + ] + } + ], + 'definitions': { + 'description': { + 'title': 'Description', + 'description': 'A description of the object', + 'type': 'string', + 'widget': 'string' + } + } +}; diff --git a/ui/src/testing/mockMetadataWizard.js b/ui/src/testing/mockMetadataWizard.js new file mode 100644 index 000000000..38b6e7a2a --- /dev/null +++ b/ui/src/testing/mockMetadataWizard.js @@ -0,0 +1,70 @@ +export const MockMetadataWizard = { + label: 'Metadata Source', + type: '@MetadataProvider', + validatorParams: [], + bindings: {}, + parser(changes, schema) { + return changes; + }, + formatter(changes, schema) { + return changes; + }, + display(changes, schema) { + return changes; + }, + getValidators() { + return {}; + }, + schema: 'api/ui/MetadataSources', + steps: [ + { + index: 1, + id: 'common', + label: 'label.sp-org-info', + fields: [ + 'name', + 'serviceEnabled' + ], + fieldsets: [ + { + type: 'group', + fields: [ + 'serviceProviderName', + 'entityId', + 'serviceEnabled', + 'organization' + ] + }, + { + type: 'group', + fields: [ + 'contacts' + ] + } + ] + }, + { + index: 2, + id: 'next', + label: 'something', + fields: [ + 'foo', + 'list' + ], + fieldsets: [ + { + type: 'group', + fields: [ + 'foo' + ] + }, + { + type: 'group', + fields: [ + 'list' + ] + } + ] + } + ] +};