Skip to content

Commit

Permalink
SHIBUI-1060 Fixed issues with 704
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 12, 2018
1 parent afce3a8 commit d5046b6
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
}
},
"required": [
"@type",
"content",
"match"
]
},
Expand All @@ -48,10 +46,7 @@
]
}
},
"required": [
"@type",
"content"
]
"required": []
}
],
"properties": {
Expand Down
10 changes: 7 additions & 3 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ label.metadata-provider-type=Metadata Provider Type
label.metadata-provider-name=Metadata Provider Name
label.select-metadata-type=Select a metadata provider type
label.metadata-provider-status=Metadata Provider Status
label.enable-provider-upon-saving=If checkbox is clicked, the metadata provider is enabled for integration with the IdP
label.enable-provider-upon-saving=Enable Metadata Provider?
label.certificate-type=Type

label.metadata-file=Metadata File
Expand Down Expand Up @@ -388,6 +388,10 @@ message.org-displayName-required=Organization Name is required.
message.org-url-required=Organization Name is required.
message.org-incomplete=These three fields must all be entered if any single field has a value.

message.content-required=Missing required property: Type
message.match-required=Missing required property: Match
message.value-required=Missing required property: Value

message.conflict=Conflict
message.data-version-contention=Data Version Contention
message.contention-new-version=A newer version of this metadata source has been saved. Below are a list of changes. You can use your changes or their changes.
Expand Down Expand Up @@ -434,7 +438,7 @@ tooltip.assertion-consumer-service-location-binding=Assertion Consumer Service L
tooltip.mark-as-default=Mark as Default
tooltip.protocol-support-enumeration=Protocol Support Enumeration
tooltip.nameid-format=Content is name identifier format which is added to all the applicable roles of the entities which match any of the following <Entity> or {{<ConditionRef>}}elements.
tooltip.enable-this-service-upon-saving=Enable this service upon saving
tooltip.enable-this-service-upon-saving=If checkbox is clicked, the metadata provider is enabled for integration with the IdP
tooltip.authentication-requests-signed=Authentication Requests Signed
tooltip.want-assertions-signed=Want Assertions Signed
tooltip.certificate-name=Certificate Name
Expand Down Expand Up @@ -520,7 +524,7 @@ tooltip.source-directory=Convenience mechanism for wiring a FilesystemLoadSaveMa
tooltip.remove-idle-entity-data=Flag indicating whether idle metadata should be removed.

tooltip.do-resolver-initialization=Initialize this resolver? In the case of Filesystem resolvers, this will cause the system to read the file and index the resolver.
tooltip.md-request-type=Options are 1) Metadata Query Protocol, 2) Template, 3) Regex.
tooltip.md-request-type=Options are 1) Metadata Query Protocol, 2) Regex.
tooltip.md-request-value=Content of the element.
tooltip.transform-ref=A reference to a transform function for the entityID. If used, the child element must be empty.
tooltip.encoding-style=Determines whether and how the entityID value will be URL encoded prior to replacement. Allowed values are: 1) "none" - no encoding is performed, 2) "form" - encoded using URL form parameter encoding (for query parameters), 3) "path" - encoded using URL path encoding, or 4) "fragment" - encoded using URL fragment encoding. The precise definition of these terms is defined in the documentation for the methods of the Guava library\u0027s UrlEscapers class.
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/domain/service/resolver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ResolverService {
headers: new HttpHeaders().set('Content-Type', 'application/xml'),
params: new HttpParams().set('spName', name)
}).pipe(catchError(error => {
return throwError({ errorCode: error.status, errorMessage: `Unable to upload file ... ${error.error}` });
return throwError({ errorCode: error.status, errorMessage: `Unable to upload file ... ${error.error.errorMessage}` });
}));
}

Expand All @@ -56,7 +56,7 @@ export class ResolverService {
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded'),
params: new HttpParams().set('spName', name)
}).pipe(catchError(error => {
return throwError({ errorCode: error.status, errorMessage: `Unable to upload file ... ${error.error}` });
return throwError({ errorCode: error.status, errorMessage: `Unable to upload file ... ${error.error.errorMessage}` });
}));
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/filter/model/nameid.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MetadataFilter } from '../../domain/model';
import { NameIDFormatFilterEntity } from '../../domain/entity/filter/nameid-format-filter';

export const NameIDFilter: FormDefinition<MetadataFilter> = {
label: 'NameIDFilter',
label: 'NameIDFormat',
type: 'NameIDFormat',
schema: '/api/ui/NameIdFormatFilter',
getEntity(filter: MetadataFilter): NameIDFormatFilterEntity {
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/metadata/provider/model/base.provider.form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ describe('BaseMetadataProviderForm', () => {

describe('parent `/` validator', () => {
const validators = BaseMetadataProviderEditor.getValidators(['foo', 'bar']);
const prop = { path: '/name', properties: { name: { type: 'string' } } };

it('should return a list of child errors', () => {
expect(validators['/']({name: 'foo'}, { path: '/name' }, {}).length).toBe(1);
expect(validators['/']({name: 'foo'}, prop, {}).length).toBe(1);
});

it('should ignore properties that don\'t exist a list of child errors', () => {
expect(validators['/']({ foo: 'bar' }, { path: '/foo' }, {})).toBeUndefined();
expect(validators['/']({ foo: 'bar' }, prop, {})).toBeUndefined();
});
});
});
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/metadata/provider/model/base.provider.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ export const BaseMetadataProviderEditor: Wizard<BaseMetadataProvider> = {
const validators = {
'/': (value, property, form_current) => {
let errors;
// iterate all customer
Object.keys(value).forEach((key) => {
const item = value[key];
const validatorKey = `/${key}`;
const validator = validators.hasOwnProperty(validatorKey) ? validators[validatorKey] : null;
const error = validator ? validator(item, { path: `/${key}` }, form_current) : null;
const error = validator ? validator(item, property.properties[key], form_current) : null;
if (error) {
errors = errors || [];
errors.push(error);
Expand Down
53 changes: 47 additions & 6 deletions ui/src/app/metadata/provider/model/dynamic-http.provider.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,54 @@ export const DynamicHttpMetadataProviderWizard: Wizard<DynamicHttpMetadataProvid
} : null;
return err;
};
validators['/metadataURL'] = (value, property, form) => {
return !UriValidator.isUri(value) ? {
code: 'INVALID_URI',

validators['/metadataRequestURLConstructionScheme'] = (value, property, form) => {
let errors;
let keys = Object.keys(property.schema.properties);

keys.forEach((item) => {
const path = `/metadataRequestURLConstructionScheme/${item}`;
const error = validators[path](value[item], property.properties[item], form);
if (error) {
errors = errors || [];
errors.push(error);
}
});
return errors;
};

validators['/metadataRequestURLConstructionScheme/content'] = (value, property, form) => {
const err = !value ? {
code: 'REQUIRED',
path: `#${property.path}`,
message: 'message.value-required',
params: [value]
} : null;
return err;
};

validators['/metadataRequestURLConstructionScheme/@type'] = (value, property, form) => {
const err = !value ? {
code: 'REQUIRED',
path: `#${property.path}`,
message: 'message.uri-valid-format',
message: 'message.type-required',
params: [value]
} : null;
return err;
};

validators['/metadataRequestURLConstructionScheme/match'] = (value, property, form) => {
if (!property.parent || !property.parent.value) {
return null;
}
const isRegex = property.parent.value['@type'] === 'Regex';
const err = isRegex && !value ? {
code: 'REQUIRED',
path: `#${property.path}`,
message: 'message.match-required',
params: [value]
} : null;
return err;
};

return validators;
Expand All @@ -40,10 +81,10 @@ export const DynamicHttpMetadataProviderWizard: Wizard<DynamicHttpMetadataProvid
label: 'label.common-attributes',
index: 2,
initialValues: [],
schema: '/api/ui/MetadataResolver/DynamicHttpMetadataResolver',
// schema: '/api/ui/MetadataResolver/DynamicHttpMetadataResolver',
schema: 'assets/schema/provider/dynamic-http.schema.json',
fields: [
'xmlId',
'metadataURL',
'requireValidMetadata',
'failFastInitialization',
'metadataRequestURLConstructionScheme'
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/schema-form/widget/array/array.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class CustomArrayComponent extends ArrayWidget implements AfterViewInit,

addItem(): void {
super.addItem();
console.log(this.formProperty.schemaValidator(this.schema));
}

getListType(property: any): string {
Expand Down
6 changes: 6 additions & 0 deletions ui/src/app/schema-form/widget/select/select.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@
<select *ngIf="schema.type === 'array'" multiple [formControl]="control" [attr.name]="name" [attr.disabled]="schema.readOnly" class="form-control">
<option *ngFor="let option of schema.items.oneOf" [ngValue]="option.enum[0]" [translate]="option.description">{{ option.description }}</option>
</select>
<small class="form-text text-danger" *ngIf="errorMessages && errorMessages.length && control.touched">
<ng-container *ngFor="let error of errorMessages; let first=first;">
<ng-container *ngIf="!first">, </ng-container>
<translate-i18n [key]="error">error</translate-i18n>
</ng-container>
</small>
<input *ngIf="schema.readOnly" [attr.name]="name" type="hidden" [formControl]="control">
</div>
56 changes: 25 additions & 31 deletions ui/src/assets/schema/provider/dynamic-http.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,6 @@
"@type",
"content"
],
"anyOf": [
{
"properties": {
"@type": {
"enum": [
"Regex"
]
}
},
"required": [
"@type",
"content",
"match"
]
},
{
"properties": {
"@type": {
"enum": [
"MetadataQueryProtocol"
]
}
},
"required": [
"@type",
"content"
]
}
],
"properties": {
"@type": {
"title": "label.md-request-type",
Expand Down Expand Up @@ -152,8 +123,8 @@
"step": 0.01
},
"placeholder": "label.real-number",
"minimum": 0,
"maximum": 1,
"minimum": 0.01,
"maximum": 0.99,
"default": null
},
"minCacheDuration": {
Expand Down Expand Up @@ -222,6 +193,29 @@
"default": null,
"pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
},
"removeIdleEntityData": {
"title": "label.remove-idle-entity-data",
"description": "tooltip.remove-idle-entity-data",
"type": "boolean",
"widget": {
"id": "boolean-radio"
},
"oneOf": [
{
"enum": [
true
],
"description": "value.true"
},
{
"enum": [
false
],
"description": "value.false"
}
],
"default": true
},
"cleanupTaskInterval": {
"title": "label.cleanup-task-interval",
"description": "tooltip.cleanup-task-interval",
Expand Down

0 comments on commit d5046b6

Please sign in to comment.