Skip to content

Commit

Permalink
Merge branch 'master' of bitbucket.org:unicon/shib-idp-ui into bugfix…
Browse files Browse the repository at this point in the history
…/SHIBUI-823
  • Loading branch information
rmathis committed Sep 5, 2018
2 parents bdf79b9 + ce9c7e8 commit ec7cd7e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 49 deletions.
10 changes: 2 additions & 8 deletions ui/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function (config) {
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-phantomjs-launcher'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-spec-reporter'),
Expand Down Expand Up @@ -46,13 +46,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_WARN,
autoWatch: false,
browsers: ['PhantomJS_custom'],
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
flags: ['--disk-cache=false']
}
},
browsers: ['ChromeHeadless'],
singleRun: true
});
};
1 change: 0 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"karma-phantomjs-launcher": "^1.0.4",
"karma-spec-reporter": "0.0.31",
"path": "^0.12.7",
"phantomjs-prebuilt": "^2.1.15",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
Expand Down
36 changes: 1 addition & 35 deletions ui/src/app/metadata/domain/service/resolver.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ describe(`Resolver Service`, () => {
});
});

afterEach(inject([HttpTestingController], (backend: HttpTestingController) => {
backend.verify();
}));

describe('query', () => {
it(`should send an expected query request`, async(inject([ResolverService, HttpTestingController],
(service: ResolverService, backend: HttpTestingController) => {
Expand All @@ -34,17 +30,7 @@ describe(`Resolver Service`, () => {
}
)));

xit(`should emit an empty array if an error is thrown`, async(inject([ResolverService, HttpTestingController],
(service: ResolverService, backend: HttpTestingController) => {
service.query().subscribe((next) => {
expect(next).toEqual([]);
});

backend.expectOne('/api/EntityDescriptors').flush(null, { status: 404, statusText: 'Not Found' });
}
)));

it(`should emit 'true' for 200 Ok`, async(inject([ResolverService, HttpTestingController],
xit(`should emit 'true' for 200 Ok`, async(inject([ResolverService, HttpTestingController],
(service: ResolverService, backend: HttpTestingController) => {
service.query().subscribe((next) => {
expect(next).toBeTruthy();
Expand All @@ -68,25 +54,5 @@ describe(`Resolver Service`, () => {
}, `GET EntityDescriptor by id`);
}
)));

xit(`should emit an error is thrown`, async(inject([ResolverService, HttpTestingController],
(service: ResolverService, backend: HttpTestingController) => {
service.find(id).subscribe((next) => {
expect(next).toBeFalsy();
});

backend.expectOne(`/api/EntityDescriptor/${id}`).flush(null, { status: 404, statusText: 'Not Found' });
}
)));

xit(`should emit 'true' for 200 Ok`, async(inject([ResolverService, HttpTestingController],
(service: ResolverService, backend: HttpTestingController) => {
service.find(id).subscribe((next) => {
expect(next).toBeTruthy();
});

backend.expectOne(`/api/EntityDescriptor/${id}`).flush(null, { status: 200, statusText: 'Ok' });
}
)));
});
});
9 changes: 9 additions & 0 deletions ui/src/app/metadata/provider/model/base.provider.form.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Wizard } from '../../../wizard/model';
import { BaseMetadataProvider } from '../../domain/model/providers';
import { UriValidator } from '../../../shared/validation/uri.validator';

export const BaseMetadataProviderEditor: Wizard<BaseMetadataProvider> = {
label: 'BaseMetadataProvider',
Expand Down Expand Up @@ -29,6 +30,14 @@ export const BaseMetadataProviderEditor: Wizard<BaseMetadataProvider> = {
params: [value]
} : null;
return err;
},
'/metadataURL': (value, property, form) => {
return !!UriValidator.isUri(value) ? {
code: 'INVALID_URI',
path: `#${property.path}`,
message: 'URI must be valid format.',
params: [value]
} : null;
}
};
return validators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { FormControl, Validators, AbstractControl, ValidatorFn } from '@angular/
import { ObjectWidget } from 'ngx-schema-form';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { distinctUntilChanged, skipWhile } from 'rxjs/operators';
import { distinctUntilChanged, skipWhile, map } from 'rxjs/operators';

import * as fromRoot from '../../../app.reducer';
import * as fromFilters from '../../../metadata/filter/reducer';

import { QueryEntityIds, ClearSearch } from '../../../metadata/filter/action/search.action';
import { EntityValidators } from '../../../metadata/domain/service/entity-validators.service';

/* istanbul ignore next */
@Component({
Expand Down Expand Up @@ -42,7 +41,9 @@ export class FilterTargetComponent extends ObjectWidget implements OnDestroy, Af

this.search
.valueChanges
.pipe(distinctUntilChanged())
.pipe(
distinctUntilChanged()
)
.subscribe(query => this.searchEntityIds(query));

this.script
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/shared/regex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { AbstractControl } from '@angular/forms';

export const URL_REGEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;
export const EMAIL_REGEX = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$/;
export const INTEGER_REGEX = /^[0-9]+$/;
26 changes: 26 additions & 0 deletions ui/src/app/shared/validation/uri.validator.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { UriValidator } from './uri.validator';
import { FormControl } from '@angular/forms';

describe('UriValidator class', () => {
describe('isUri method', () => {
it('should return false if invalid', () => {
expect(UriValidator.isUri('foo')).toBe(false);
});

it('should return true if valid', () => {
expect(UriValidator.isUri('http://foo.bar')).toBe(true);
});
});

describe('uri method', () => {
it('should return a validation object if invalid', () => {
let form: FormControl = new FormControl('foo');
expect(UriValidator.uri(form)).toEqual({uri: true});
});

it('should return null if valid', () => {
let form: FormControl = new FormControl('http://goo.gle');
expect(UriValidator.uri(form)).toBeNull();
});
});
});
18 changes: 18 additions & 0 deletions ui/src/app/shared/validation/uri.validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AbstractControl, ValidationErrors } from '@angular/forms';

export class UriValidator {
static uri(control: AbstractControl): ValidationErrors | null {
return UriValidator.isUri(control.value) ? null : { uri: true };
}

static isUri(value: string): boolean {
try {
let url = new URL(value);
} catch (err) {
return false;
}
return true;
}
}

export default UriValidator;

0 comments on commit ec7cd7e

Please sign in to comment.