[ADF-3941] Settings Page - SSO -> Identity Host is not visible when open the page for the first time (#4197)

* [ADF-3941] Show identityHost for both ECM and BPM

* [ADF-3941] Added test
This commit is contained in:
Deepak Paul 2019-01-23 20:42:45 +05:30 committed by Maurizio Vitale
parent b86a385c36
commit 44b18659a1
3 changed files with 23 additions and 11 deletions

View File

@ -53,10 +53,15 @@
{{ 'CORE.HOST_SETTINGS.REQUIRED'| translate }}
</mat-error>
</mat-form-field>
<mat-form-field *ngIf="hasIdentity" class="adf-full-width" floatLabel="Identity Host">
</mat-card-content>
</ng-container>
<ng-container *ngIf="isOAUTH()">
<mat-card-content>
<mat-form-field class="adf-full-width" floatLabel="Identity Host">
<mat-label>Identity Host</mat-label>
<input matInput name="identityHost" id="identityHost" formControlName="identityHost"
placeholder="http(s)://host|ip:port(/path)">
placeholder="http(s)://host|ip:port(/path)">
<mat-error *ngIf="identityHost.hasError('pattern')">
{{ 'CORE.HOST_SETTINGS.NOT_VALID'| translate }}
</mat-error>

View File

@ -336,6 +336,17 @@ describe('HostSettingsComponent', () => {
bpmUrlInput.dispatchEvent(new Event('input'));
});
it('should have a required identityUrl and invalid form when the identityUrl is missing', (done) => {
component.form.statusChanges.subscribe((status: string) => {
expect(status).toEqual('INVALID');
expect(component.identityHost.hasError('required')).toBeTruthy();
done();
});
identityUrlInput.value = '';
identityUrlInput.dispatchEvent(new Event('input'));
});
it('should have an invalid form when the identity url inserted is wrong', (done) => {
const url = 'wrong';

View File

@ -43,7 +43,6 @@ export class HostSettingsComponent implements OnInit {
providers: string[] = ['BPM', 'ECM', 'ALL'];
showSelectProviders = true;
hasIdentity = false;
form: FormGroup;
@ -83,13 +82,16 @@ export class HostSettingsComponent implements OnInit {
if (authType === 'OAUTH') {
this.addOAuthFormGroup();
this.addIdentityHostFormControl();
}
this.form.get('authType').valueChanges.subscribe((value) => {
if (value === 'BASIC') {
this.form.removeControl('oauthConfig');
this.form.removeControl('identityHost');
} else {
this.addOAuthFormGroup();
this.addIdentityHostFormControl();
}
});
@ -102,14 +104,11 @@ export class HostSettingsComponent implements OnInit {
private removeFormGroups() {
this.form.removeControl('bpmHost');
this.form.removeControl('ecmHost');
this.form.removeControl('identityHost');
this.hasIdentity = false;
}
private addFormGroups() {
this.addBPMFormControl();
this.addECMFormControl();
this.addIdentityHostFormControl();
}
private addOAuthFormGroup() {
@ -125,11 +124,8 @@ export class HostSettingsComponent implements OnInit {
}
private addIdentityHostFormControl() {
if ((this.isOAUTH()) && !this.identityHost) {
const identityHostFormControl = this.createIdentityFormControl();
this.form.addControl('identityHost', identityHostFormControl);
this.hasIdentity = true;
}
const identityHostFormControl = this.createIdentityFormControl();
this.form.addControl('identityHost', identityHostFormControl);
}
private addECMFormControl() {