diff options
author | Patrick Brady <patrick.brady@att.com> | 2020-03-26 16:14:17 -0700 |
---|---|---|
committer | Patrick Brady <patrick.brady@att.com> | 2020-03-26 16:14:53 -0700 |
commit | aa60945d2903ff60c4cdeebae76fbf569c91e444 (patch) | |
tree | 3569bf253b35703194e97ebb888caf152d3e39e0 /src/app/vnfs | |
parent | 0141df20b1f533cd2acabdf7ea986aebab8d6868 (diff) |
Revert "Authentication support for cdt"
There appear to be problems with some fields saving in cdt
caused by this change.
This reverts commit 0141df20b1f533cd2acabdf7ea986aebab8d6868.
Change-Id: Iee40058de9870afdac608db7851fcfc206102822
Signed-off-by: Patrick Brady <patrick.brady@att.com>
Issue-ID: APPC-1854
Diffstat (limited to 'src/app/vnfs')
12 files changed, 43 insertions, 116 deletions
diff --git a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts index 216a4df..440993d 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) => { - sessionStorage['userId'] = 'abc@xyz.com'; + localStorage['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) => { - sessionStorage['userId'] = 'abc@xyz.com'; + localStorage['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 1938030..1e7e752 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['userId']; + let userId = localStorage['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 a2e26b8..1c57478 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) => { - sessionStorage['userId'] = 'abc@xyz.com'; + localStorage['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) => { - sessionStorage['userId'] = ''; + localStorage['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 add5b5e..ae4aec4 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['apiToken']; - private userId = sessionStorage['userId']; + private apiToken = localStorage['apiToken']; + private userId = localStorage['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 7686839..64f1159 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['apiToken']; - userId = sessionStorage['userId']; + apiToken = localStorage['apiToken']; + userId = localStorage['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 ac89a2d..a3ef4f7 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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.postWithAuth({ + this.httpUtils.post({ 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 ab1a7b3..f18fe6c 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['apiToken']; - userId = sessionStorage['userId']; + apiToken = localStorage['apiToken']; + userId = localStorage['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 913e5e9..cee9629 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['apiToken']; + apiToken = localStorage['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 = sessionStorage['userId']; + userId = localStorage['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 696e601..49f4f42 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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 = sessionStorage['apiToken']; + const apiToken = localStorage['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 = sessionStorage['userId']; + x.userID = localStorage['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.postWithAuth({ + this.httpUtil.post({ 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 069583e..3f18b72 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -32,10 +32,6 @@ 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" @@ -47,4 +43,4 @@ limitations under the License. </div> </div> </div> -</div> +</div>
\ No newline at end of file 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 bf8431b..712d1bf 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 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(); - // sessionStorage['userId'] = "testUser" + // localStorage['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(sessionStorage['userId']).toBe('test Usr'); + expect(localStorage['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 7ed087e..c62e9bb 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-2020 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -23,24 +23,19 @@ 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, - private http: Http, private ngProgress: NgProgress) { + constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute + ) { } ngOnInit() { @@ -49,57 +44,12 @@ export class userloginFormComponent implements OnInit { getData() { - 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"); - + localStorage['userId'] = this.userId; + localStorage['apiToken'] = this.utiltiy.randomId(); + EmitterService + .get('userLogin') + .emit(this.userId); + this.router.navigateByUrl(this.returnUrl); } validateUserName(){ @@ -107,7 +57,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 in username'; + this.errorMessage = 'Leading and trailing space is not allowed'; this.invalid = true; } else if(this.userId.includes(' ')){ this.errorMessage = 'More than one space is not allowed in username'; @@ -120,24 +70,5 @@ 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 = ''; - } - } } |