diff options
Diffstat (limited to 'src/app/vnfs')
12 files changed, 116 insertions, 43 deletions
diff --git a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts index 440993d..216a4df 100644 --- a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts +++ b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts @@ -51,7 +51,7 @@ describe('LogginGuard', () => { }); it('be able to return true when referenceNameObjects is defined', inject([GCAuthGuardService, MappingEditorService], (service: GCAuthGuardService, mapService: MappingEditorService) => { - localStorage['userId'] = 'abc@xyz.com'; + sessionStorage['userId'] = 'abc@xyz.com'; mapService.referenceNameObjects = { data : 'data'}; let route : ActivatedRouteSnapshot; let state: RouterStateSnapshot; @@ -61,7 +61,7 @@ describe('LogginGuard', () => { })); it('stop routing if referenceNameObjects is not defined', inject([GCAuthGuardService, MappingEditorService, NgbModal], (service: GCAuthGuardService, mapService: MappingEditorService, ngbModal: NgbModal) => { - localStorage['userId'] = 'abc@xyz.com'; + sessionStorage['userId'] = 'abc@xyz.com'; mapService.referenceNameObjects = undefined; let spy = spyOn(NgbModal.prototype, 'open').and.returnValue(Promise.resolve(true)); let route : ActivatedRouteSnapshot; diff --git a/src/app/vnfs/LoginGuardService/Login-guard-service.ts b/src/app/vnfs/LoginGuardService/Login-guard-service.ts index 1e7e752..1938030 100644 --- a/src/app/vnfs/LoginGuardService/Login-guard-service.ts +++ b/src/app/vnfs/LoginGuardService/Login-guard-service.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. Copyright (C) 2018 IBM. =================================================================== @@ -35,7 +35,7 @@ export class LoginGuardService implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - let userId = localStorage['userId']; + let userId = sessionStorage['userId']; if (userId != null && userId != undefined && userId != '') { return true; } else { @@ -44,4 +44,4 @@ export class LoginGuardService implements CanActivate { } } -}
\ No newline at end of file +} diff --git a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts index 1c57478..a2e26b8 100644 --- a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts +++ b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts @@ -51,14 +51,14 @@ describe('LogginGuard', () => { }); it('be able to hit route when user is logged in', inject([LoginGuardService], (service: LoginGuardService) => { - localStorage['userId'] = 'abc@xyz.com'; + sessionStorage['userId'] = 'abc@xyz.com'; let route : ActivatedRouteSnapshot; let state: RouterStateSnapshot; expect(service.canActivate(route, state)).toBe(true); })); it('be able to navigate to login page when user is not logged in', inject([LoginGuardService], (service: LoginGuardService) => { - localStorage['userId'] = ''; + sessionStorage['userId'] = ''; let route : ActivatedRouteSnapshot; let mockSnapshot:any = jasmine.createSpyObj<RouterStateSnapshot>("RouterStateSnapshot", ['toString']); expect(service.canActivate(route, mockSnapshot)).toBe(false); diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts index ae4aec4..add5b5e 100644 --- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts +++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. Copyright (C) 2018 IBM. =================================================================== @@ -63,8 +63,8 @@ export class ParameterDefinitionService { public myKeyFileName = null; public myPdFileName = null; private selectedActionReference: any; - private apiToken = localStorage['apiToken']; - private userId = localStorage['userId']; + private apiToken = sessionStorage['apiToken']; + private userId = sessionStorage['userId']; public versionNoForApiCall=require('../../../../cdt.application.properties.json').versionNoForApiCall; constructor(private mappingEditorService: MappingEditorService, @@ -556,4 +556,4 @@ export class ParameterDefinitionService { this.populatePD(fileModel); return this.displayParamObjects; } -}
\ No newline at end of file +} diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts index 64f1159..7686839 100644 --- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts +++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. Copyright (C) 2018 IBM Intellectual Property. All rights reserved. =================================================================== @@ -72,8 +72,8 @@ export class ParameterComponent implements OnInit { public confirmation: boolean; public showConfirmation: boolean; public test: boolean; - apiToken = localStorage['apiToken']; - userId = localStorage['userId']; + apiToken = sessionStorage['apiToken']; + userId = sessionStorage['userId']; public initialData: any; public intialData: any; public initialAction: any; diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts index a3ef4f7..ac89a2d 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -939,7 +939,7 @@ export class ReferenceDataformComponent implements OnInit { let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload); this.ngProgress.start(); - this.httpUtils.post({ + this.httpUtils.postWithAuth({ url: environment.getDesigns, data: payload }).subscribe((resp) => { diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts index f18fe6c..ab1a7b3 100644 --- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Copyright (C) 2018 IBM Intellectual Property. All rights reserved. =================================================================== @@ -77,8 +77,8 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { action: any = ''; artifactName: any = ''; enableMerge: boolean = false; - apiToken = localStorage['apiToken']; - userId = localStorage['userId']; + apiToken = sessionStorage['apiToken']; + userId = sessionStorage['userId']; identifier: any; public uploadTypes = [ @@ -435,4 +435,4 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { } } -}
\ No newline at end of file +} diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts index cee9629..913e5e9 100644 --- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -75,7 +75,7 @@ export class GoldenConfigurationComponent implements OnInit { enableBrowse: boolean = true; enableMerge: boolean = false; uploadValidationSuccess: boolean = false; - apiToken = localStorage['apiToken']; + apiToken = sessionStorage['apiToken']; public appDataObject: any; public downloadDataObject: any; public checkNameEntered: boolean = true; @@ -130,7 +130,7 @@ export class GoldenConfigurationComponent implements OnInit { public fileType: any = ''; public actionType: any; public myfileName: any; - userId = localStorage['userId']; + userId = sessionStorage['userId']; public artifactRequest: ArtifactRequest = new ArtifactRequest(); public showUploadStatus: boolean = false; public uploadStatus: boolean = false; diff --git a/src/app/vnfs/myvnfs/myvnfs.component.ts b/src/app/vnfs/myvnfs/myvnfs.component.ts index 49f4f42..696e601 100644 --- a/src/app/vnfs/myvnfs/myvnfs.component.ts +++ b/src/app/vnfs/myvnfs/myvnfs.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Copyright (C) 2018 IBM. =================================================================== @@ -63,7 +63,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy { sessionStorage.setItem('updateParams', undefined); this.mappingEditorService.latestAction = undefined; - const apiToken = localStorage['apiToken']; + const apiToken = sessionStorage['apiToken']; const data = { 'input': { @@ -75,7 +75,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy { } }; const x = JSON.parse(data.input['design-request']['payload']); - x.userID = localStorage['userId']; + x.userID = sessionStorage['userId']; data.input['design-request']['payload'] = JSON.stringify(x); // console.log("input to payload====", JSON.stringify(data)); this.getArtifacts(data); @@ -89,7 +89,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy { getArtifacts(data) { let tempObj: any; this.ngProgress.start(); - this.httpUtil.post({ + this.httpUtil.postWithAuth({ url: environment.getDesigns, data: data }) @@ -233,4 +233,4 @@ export class MyvnfsComponent implements OnInit, OnDestroy { } -}
\ No newline at end of file +} diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.html b/src/app/vnfs/userlogin-form/userlogin-form.component.html index 3f18b72..069583e 100644 --- a/src/app/vnfs/userlogin-form/userlogin-form.component.html +++ b/src/app/vnfs/userlogin-form/userlogin-form.component.html @@ -1,7 +1,7 @@ <!-- ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -32,6 +32,10 @@ limitations under the License. [(ngModel)]="userId" name="userId" value="" #user="ngModel" (ngModelChange)="validateUserName()"> <span class="error-message">{{errorMessage}}</span> </div> + <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> + <input type="password" placeholder="Enter password" class="mdl-textfield__input" id="password" required + [(ngModel)]="password" name="password" value="" (ngModelChange)="validatePassword()" > + </div> <div class="form-group text-right"> <button type="submit" [disabled]="invalid" @@ -43,4 +47,4 @@ limitations under the License. </div> </div> </div> -</div>
\ No newline at end of file +</div> diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts index 712d1bf..bf8431b 100644 --- a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts +++ b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. Modification Copyright (C) 2018 IBM =================================================================== @@ -64,7 +64,7 @@ describe('userloginFormComponent', () => { fixture = TestBed.createComponent(userloginFormComponent); component = fixture.componentInstance; fixture.detectChanges(); - // localStorage['userId'] = "testUser" + // sessionStorage['userId'] = "testUser" component.userId = 'test Usr'; }); @@ -99,7 +99,7 @@ describe('userloginFormComponent', () => { expect(url.length).toBe(5); expect(url[0]).toEqual('/'); expect(url[1]).toEqual('h'); - expect(localStorage['userId']).toBe('test Usr'); + expect(sessionStorage['userId']).toBe('test Usr'); })); it('test validateUserName function', () => { diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.ts index c62e9bb..7ed087e 100644 --- a/src/app/vnfs/userlogin-form/userlogin-form.component.ts +++ b/src/app/vnfs/userlogin-form/userlogin-form.component.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -23,19 +23,24 @@ import {Component, OnInit} from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import {EmitterService} from '../../shared/services/emitter.service'; +import { environment } from '../../../environments/environment'; +import { HttpUtilService } from '../../shared/services/httpUtil/http-util.service'; import {Router} from '@angular/router'; +import { NgProgress } from 'ngx-progressbar'; import {UtilityService} from '../../shared/services/utilityService/utility.service'; +import { Http, Response, Headers, RequestOptions } from '@angular/http'; @Component({selector: 'app-mvnfs-form', templateUrl: './userlogin-form.component.html', styleUrls: ['./userlogin-form.component.css']}) export class userloginFormComponent implements OnInit { userId: string = ''; + password: string = ''; returnUrl:string invalid = true; errorMessage = ''; - constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute - ) { + constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute, + private http: Http, private ngProgress: NgProgress) { } ngOnInit() { @@ -44,12 +49,57 @@ export class userloginFormComponent implements OnInit { getData() { - localStorage['userId'] = this.userId; - localStorage['apiToken'] = this.utiltiy.randomId(); - EmitterService - .get('userLogin') - .emit(this.userId); - this.router.navigateByUrl(this.returnUrl); + this.ngProgress.start(); + var getHeader = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON + var authStr = btoa(this.userId + ':' + this.password); + const options = { + headers: new Headers({ + 'Content-Type': 'application/json', + 'Authorization': 'Basic ' + authStr + }), + observe: 'response' + }; + const data = { + 'input': { + 'design-request': { + 'request-id': '1', + 'action': 'getDesigns', + 'payload': '{"userID": "","filter":"reference"}' + } + } + }; + const x = JSON.parse(data.input['design-request']['payload']); + x.userID = this.userId; + data.input['design-request']['payload'] = JSON.stringify(x); + console.log("auth " + btoa(this.userId + ':' + this.password)); + this.http.post(environment.getDesigns,data,options).subscribe(resp => { + console.log("status " + resp.status); + if(resp.status == 200){ + console.log('logged in'); + sessionStorage['userId'] = this.userId; + sessionStorage['apiToken'] = this.utiltiy.randomId(); + sessionStorage['auth'] = authStr; + EmitterService + .get('userLogin') + .emit(this.userId); + this.router.navigateByUrl(this.returnUrl); + } else { + console.log("Invalid user or password"); + this.invalid = true; + this.errorMessage = 'Invalid user or password'; + } + }, error => { + console.log(error); + if(error.status == 401){ + this.invalid = true; + this.errorMessage = 'Invalid user or password'; + } else { + this.invalid = true; + this.errorMessage = 'Incorrect login or connection error.'; + } + }); + console.log("After"); + } validateUserName(){ @@ -57,7 +107,7 @@ export class userloginFormComponent implements OnInit { this.errorMessage = ''; this.invalid = true; }else if(this.userId.startsWith(' ') || this.userId.endsWith(' ')){ - this.errorMessage = 'Leading and trailing space is not allowed'; + this.errorMessage = 'Leading and trailing space is not allowed in username'; this.invalid = true; } else if(this.userId.includes(' ')){ this.errorMessage = 'More than one space is not allowed in username'; @@ -70,5 +120,24 @@ export class userloginFormComponent implements OnInit { this.errorMessage = ''; } } + + validatePassword(){ + if (!this.password.trim() || this.password.length < 1) { + this.errorMessage = ''; + this.invalid = true; + }else if(this.password.startsWith(' ') || this.password.endsWith(' ')){ + this.errorMessage = 'Leading and trailing space is not allowed in password'; + this.invalid = true; + } else if(this.password.includes(' ')){ + this.errorMessage = 'More than one space is not allowed in password'; + this.invalid = true; + } else if(this.password.length > 50) { + this.errorMessage = 'Password should be of minimum one character and maximum 50 character'; + this.invalid = true; + }else { + this.invalid = false; + this.errorMessage = ''; + } + } } |