summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamed Asgar Samiulla(ma926a) <ma926a@us.att.com>2018-04-02 19:00:49 +0530
committerSkip Wonnell <skip@att.com>2018-04-09 11:24:18 -0500
commitd7dffc2d1c65788e68a7fabdc16e5afd90de0f67 (patch)
treea5fef0028c4c325f11c464c8cfb39858ecc5ac8b
parentf27d5549734324727a5432f6ff663b0880425f47 (diff)
[Appc-1806] Login for Test screen, test api urls.
Test API urls corrected and vserverid removed from poll request. Issue-ID: APPC-831 Change-Id: I0bc616888afee8683ccbf5238980e97c6ca51af6 Signed-off-by: Mohamed Asgar Samiulla(ma926a) <ma926a@us.att.com>
-rw-r--r--src/app/app.module.ts7
-rw-r--r--src/app/app.routing.ts27
-rw-r--r--src/app/test/test.component.spec.ts157
-rw-r--r--src/app/test/test.component.ts22
-rw-r--r--src/app/vnfs/LoginGuardService/Login-guard-service.ts16
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.ts16
-rw-r--r--src/app/vnfs/vnf.routing.ts35
7 files changed, 147 insertions, 133 deletions
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 4824351..df9bf07 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -16,8 +16,6 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -36,16 +34,17 @@ import {RouterModule} from '@angular/router';
import {TestComponent} from './test/test.component';
import {AboutUsComponent} from './about-us/aboutus.component';
import {NgProgressModule} from 'ngx-progressbar';
+import {LoginGuardService} from './vnfs/LoginGuardService/Login-guard-service';
@NgModule({
declarations: [AppComponent, TestComponent, AboutUsComponent],
imports: [BrowserModule, FormsModule, HomeModule, SharedModule.forRoot(),
NgbModule.forRoot(), NoopAnimationsModule, AppRoutingModule, SimpleNotificationsModule, NgProgressModule],
exports: [RouterModule],
- providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],
+ providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}, LoginGuardService],
bootstrap: [AppComponent]
})
export class AppModule {
-} \ No newline at end of file
+}
diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts
index 234487e..edc7323 100644
--- a/src/app/app.routing.ts
+++ b/src/app/app.routing.ts
@@ -16,36 +16,40 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
-import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
+
+import {AboutUsComponent} from './about-us/aboutus.component';
+import { CanActivate } from '@angular/router';
+import {HelpComponent} from './shared/components/help/help/help.component';
import {HomeComponent} from './home/home/home.component';
+import { LoginGuardService } from './vnfs/LoginGuardService/Login-guard-service';
import {LogoutComponent} from './shared/components/logout/logout.component';
-import {HelpComponent} from './shared/components/help/help/help.component';
-import {AboutUsComponent} from './about-us/aboutus.component';
+import {NgModule} from '@angular/core';
import {TestComponent} from './test/test.component';
const routes: Routes = [
{
path: 'home',
- component: HomeComponent
+ component: HomeComponent,
}, {
path: 'vnfs',
loadChildren: './vnfs/vnfs.module#VnfsModule'
}, {
path: 'test',
- component: TestComponent
+ component: TestComponent,
+ canActivate:[LoginGuardService]
},
{
path: 'help',
- component: HelpComponent
+ component: HelpComponent,
+ canActivate:[LoginGuardService]
}, {
path: 'aboutUs',
- component: AboutUsComponent
+ component: AboutUsComponent,
+ canActivate:[LoginGuardService]
}, {
path: 'logout',
component: LogoutComponent
@@ -58,7 +62,8 @@ const routes: Routes = [
@NgModule({
imports: [RouterModule.forRoot(routes)],
- exports: [RouterModule]
+
+exports: [RouterModule]
})
export class AppRoutingModule {
-} \ No newline at end of file
+}
diff --git a/src/app/test/test.component.spec.ts b/src/app/test/test.component.spec.ts
index 15dde6c..997cd26 100644
--- a/src/app/test/test.component.spec.ts
+++ b/src/app/test/test.component.spec.ts
@@ -16,11 +16,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
============LICENSE_END============================================
*/
-import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
+/* tslint:disable:no-unused-variable */
+
+// Modules
+import { async, ComponentFixture, TestBed,inject } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -34,7 +36,10 @@ import 'rxjs/add/observable/from';
import 'rxjs/add/observable/empty';
import 'rxjs/add/observable/throw';
+// Component
import { TestComponent } from './test.component';
+
+// Services
import { NotificationService } from '../shared/services/notification.service';
import { ParamShareService } from '.././shared/services/paramShare.service';
import { MappingEditorService } from '../shared/services/mapping-editor.service';
@@ -44,7 +49,7 @@ import { environment } from '../.././environments/environment';
import { NgProgress } from 'ngx-progressbar';
import { NgProgressModule } from 'ngx-progressbar';
-describe('TestComponent', () => {
+describe( 'TestComponent', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;
@@ -52,19 +57,19 @@ describe('TestComponent', () => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [
- FormsModule,
- RouterTestingModule,
- SimpleNotificationsModule,
- HttpModule,
- NgProgressModule
+ FormsModule,
+ RouterTestingModule,
+ SimpleNotificationsModule,
+ HttpModule,
+ NgProgressModule
],
providers: [
- NotificationService,
- ParamShareService,
- MappingEditorService,
- HttpUtilService,
- UtilityService,
- NgProgress, MockBackend, BaseRequestOptions,
+ NotificationService,
+ ParamShareService,
+ MappingEditorService,
+ HttpUtilService,
+ UtilityService,
+ NgProgress,MockBackend, BaseRequestOptions,
{
provide: Http,
useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
@@ -74,7 +79,7 @@ describe('TestComponent', () => {
}
]
})
- .compileComponents();
+ .compileComponents();
}));
beforeEach(() => {
@@ -84,28 +89,26 @@ describe('TestComponent', () => {
});
it('should ...', inject([HttpUtilService], (service: HttpUtilService) => {
- let spy = spyOn(service, 'post').and.returnValue(Observable.empty());
fixture.detectChanges(); // onInit()
component.pollTestStatus();
-
+
expect(service).toBeTruthy();
-
}));
-
+
// Test download Method
describe('Test download Method', () => {
it('Should have download method', () => {
expect(component.download).toBeDefined();
});
- it('test if apiRequest if true', inject([SimpleNotificationsModule], (service: SimpleNotificationsModule) => {
- component.apiRequest = '{"input":{"common-header":{"timestamp":"2018-03-05T07:41:14.329Z","api-ver":"2.00","originator-id":"CDT","request-id":"1520235674330","sub-request-id":"1520235674330","flags":{"mode":"NORMAL","force":"TRUE","ttl":3600}},"action":"ConfigModify","action-identifiers":{"vnf-id":"testVnf","vserver-id":"test"},"payload":""';
+ it('test if apiRequest if true', inject( [SimpleNotificationsModule], (service: SimpleNotificationsModule) => {
+ component.apiRequest = '{"input":{"common-header":{"timestamp":"2018-03-05T07:41:14.329Z","api-ver":"2.00","originator-id":"CDT","request-id":"1520235674330","sub-request-id":"1520235674330","flags":{"mode":"NORMAL","force":"TRUE","ttl":3600}},"action":"ConfigModify","action-identifiers":{"vnf-id":"ibcx0001","vserver-id":"test"},"payload":""';
component.apiResponse = '';
- component.action = 'ConfigModify';
- component.actionIdentifiers['vnf-id'] = 'testVnf';
+ component.action = 'ConfigModify';
+ component.actionIdentifiers['vnf-id'] = 'ibcx0001';
let fileName = 'test_' + component.action + '_' + component.actionIdentifiers['vnf-id'] + '_request';
- let theJSON = component.apiRequest;
+ let theJSON = component.apiRequest;
var blob = new Blob([theJSON], {
type: 'text/json'
});
@@ -123,10 +126,10 @@ describe('TestComponent', () => {
}));
it('test method if apiResponse is true', () => {
- component.apiResponse = '{"input":{"common-header":{"timestamp":"2018-03-05T07:41:14.329Z","api-ver":"2.00","originator-id":"CDT","request-id":"1520235674330","sub-request-id":"1520235674330","flags":{"mode":"NORMAL","force":"TRUE","ttl":3600}},"action":"ConfigModify","action-identifiers":{"vnf-id":"testvnf","vserver-id":"test"},"payload":""';
+ component.apiResponse = '{"input":{"common-header":{"timestamp":"2018-03-05T07:41:14.329Z","api-ver":"2.00","originator-id":"CDT","request-id":"1520235674330","sub-request-id":"1520235674330","flags":{"mode":"NORMAL","force":"TRUE","ttl":3600}},"action":"ConfigModify","action-identifiers":{"vnf-id":"ibcx0001","vserver-id":"test"},"payload":""';
component.apiRequest = '';
- component.action = 'ConfigModify';
- component.actionIdentifiers['vnf-id'] = 'testvnf';
+ component.action = 'ConfigModify';
+ component.actionIdentifiers['vnf-id'] = 'ibcx0001';
let fileName = 'test_' + component.action + '_' + component.actionIdentifiers['vnf-id'] + '_response';
let theJSON = component.apiRequest;
var blob = new Blob([theJSON], {
@@ -152,7 +155,7 @@ describe('TestComponent', () => {
});
it('Test abortTest Method', () => {
- const temp = component.abortTest();
+ component.abortTest();
expect(component.enableBrowse).toBeTruthy();
expect(component.enableTestButton).toBeTruthy();
expect(component.enablePollButton).toBeTruthy();
@@ -177,9 +180,9 @@ describe('TestComponent', () => {
it('should execute if file extension is XLS, XLSX', () => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.XLS", { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" })
+ let file = new File(["testing"], "foo.XLS", {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})
let fileExtension = 'XLS';
- let event = { isTrusted: true, type: "change", target: { files: [file] } }
+ let event = { isTrusted: true, type: "change", target: {files: [file]} }
component.upload(event);
@@ -189,10 +192,10 @@ describe('TestComponent', () => {
it('should return an error if file extension is not XLS, XLSX', () => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.doc", { type: "" })
+ let file = new File(["testing"], "foo.doc", {type: ""})
let fileExtension = 'doc';
- let event = { isTrusted: true, type: "change", target: { files: [file] } }
-
+ let event = { isTrusted: true, type: "change", target: {files: [file]} }
+
component.upload(event);
expect(reader instanceof FileReader).toBeTruthy();
@@ -200,7 +203,7 @@ describe('TestComponent', () => {
});
it('Should return an error is files length is not equal to 1', () => {
-
+
});
});
@@ -208,11 +211,11 @@ describe('TestComponent', () => {
describe('Test processUploadedFile Method', () => {
it('should return valid payload', () => {
let data = [
- { "TagName": "action", "Value": "ConfigModify" },
- { "List Name": "action-identifiers", "TagName": "vserver-id", "Value": "test" },
- { "List Name": "payload", "List Name_1": "request-parameters", "TagName": "vnf-name", "Value": "testVnf" },
- { "List Name": "payload", "List Name_1": "request-parameters", "List Name_2": "[vm]", "List Name_3": "vnfc", "TagName": "vnfc-name", "Value": "testVnfcName" },
- { "List Name": "payload", "List Name_1": "configuration-parameters", "TagName": "testConfigParam", "Value": "testConfigValue" }
+ {"TagName":"action","Value":"ConfigModify"},
+ {"List Name":"action-identifiers","TagName":"vserver-id","Value":"test"},
+ {"List Name":"payload","List Name_1":"request-parameters","TagName":"vnf-name","Value":"ibcx0001"},
+ {"List Name":"payload","List Name_1":"request-parameters","List Name_2":"[vm]","List Name_3":"vnfc","TagName":"vnfc-name","Value":"ibcx0001vm001ssc001"},
+ {"List Name":"payload","List Name_1":"configuration-parameters","TagName":"CORE_NETWORK_DEFAULT_GATEWAY","Value":"192.168.30.44"}
]
let payload = component.processUploadedFile(data);
@@ -221,9 +224,9 @@ describe('TestComponent', () => {
// Test uploadedFileResult Method
describe('Test uploadedFileResult', () => {
- it('should return success message', inject([SimpleNotificationsModule], (service: SimpleNotificationsModule) => {
- component.action = 'ConfigModify';
- component.actionIdentifiers['vnf-id'] = 'testvnf';
+ it('should return success message', inject([SimpleNotificationsModule],(service: SimpleNotificationsModule) => {
+ component.action = 'ConfigModify';
+ component.actionIdentifiers['vnf-id'] = 'ibcx0001';
component.uploadedFileResult();
@@ -231,7 +234,7 @@ describe('TestComponent', () => {
}));
it('should return error message', inject([SimpleNotificationsModule], (service: SimpleNotificationsModule) => {
- component.action = '';
+ component.action = '';
component.actionIdentifiers['vnf-id'] = '';
component.uploadedFileResult();
@@ -242,28 +245,27 @@ describe('TestComponent', () => {
// Test constructTestPayload Method
describe('Test constructTestPayload Method', () => {
- //3rd , 4th columnd, tag name , tag value
it('Should have constructTestPayload method', () => {
expect(component.constructTestPayload).toBeDefined();
});
it('test if listName2, listName3 are undefined', () => {
- let temp = component.constructTestPayload(undefined, undefined, 'vnfc-type', 'testvnfc');
- expect(component.subPayload['vnfc-type']).toEqual('testvnfc')
+ let temp = component.constructTestPayload(undefined, undefined, 'vnfc-type', 'vISBC - ssc');
+ expect(component.subPayload['vnfc-type']).toEqual('vISBC - ssc')
});
it('test if lastName2 is not undefined', () => {
- let temp = component.constructTestPayload(['vm'], undefined, 'vnfc-type', 'testvnfc');
- expect(typeof (component.vmJson)).toEqual('object');
- expect(typeof (component.vnfcJson)).toEqual('object');
- expect(component.vmJson['vnfc-type']).toBe('testvnfc');
+ let temp = component.constructTestPayload(['vm'], undefined, 'vnfc-type', 'vISBC - ssc');
+ expect(typeof(component.vmJson)).toEqual('object');
+ expect(typeof(component.vnfcJson)).toEqual('object');
+ expect(component.vmJson['vnfc-type']).toBe('vISBC - ssc');
expect(component.flag).toBe(0);
});
it('test if lastNmae2, lastName3 are not undefined', () => {
- let temp = component.constructTestPayload(['vm'], 'vnfc', 'vnfc-type', 'testvnfc');
- expect(component.vnfcJson['vnfc-type']).toEqual('testvnfc');
- expect(component.vmJson['vnfc']['vnfc-type']).toEqual('testvnfc');
+ let temp = component.constructTestPayload(['vm'], 'vnfc', 'vnfc-type', 'vISBC - ssc');
+ expect(component.vnfcJson['vnfc-type']).toEqual('vISBC - ssc');
+ expect(component.vmJson['vnfc']['vnfc-type']).toEqual('vISBC - ssc');
expect(component.flag).toBe(1);
})
});
@@ -285,28 +287,28 @@ describe('TestComponent', () => {
expect(component.testVnf).toBeDefined();
});
- it('should return response on success', inject([MockBackend], (mockBackend: MockBackend) => {
+ it('should return response on success', inject([MockBackend], (mockBackend: MockBackend) => {
let mockData = 'testing';
let response = new ResponseOptions({
body: JSON.stringify(mockData)
});
const baseResponse = new Response(response);
mockBackend.connections.subscribe(
- (c: MockConnection) => {
+ (c: MockConnection) => {
c.mockRespond(baseResponse)
}
);
- component.action = 'ConfigModify';
-
+ component.action = 'ConfigModify';
+
component.testVnf();
}));
- it('should return an error if fails', inject([HttpUtilService], (httpUtilService: HttpUtilService) => {
+ it('should return an error if fails', inject([HttpUtilService],( httpUtilService: HttpUtilService) => {
let error = 'Error in connecting to APPC Server';
let spy = spyOn(httpUtilService, 'post').and.returnValue(Observable.throw(error));
- component.action = 'ConfigModify';
-
+ component.action = 'ConfigModify';
+
component.testVnf();
expect(spy).toHaveBeenCalled();
@@ -317,11 +319,9 @@ describe('TestComponent', () => {
}));
it('test setTimeout', inject([NgProgress], (ngProgress: NgProgress) => {
- let spy = spyOn(ngProgress, 'done');
- component.action = 'ConfigModify';
-
+ component.action = 'ConfigModify';
+
component.testVnf();
-
}));
});
@@ -334,7 +334,7 @@ describe('TestComponent', () => {
it('should call fake server', inject([MockBackend], (mockBackend: MockBackend) => {
component.requestId = new Date().getTime().toString();
component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"FAILED\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"FAILED\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
let response = new ResponseOptions({
body: JSON.stringify(mockData)
});
@@ -342,14 +342,14 @@ describe('TestComponent', () => {
mockBackend.connections.subscribe(
(c: MockConnection) => c.mockRespond(baseResponse)
);
-
+
component.pollTestStatus();
}));
it('should call fake server if status is success', inject([MockBackend], (mockBackend: MockBackend) => {
component.requestId = new Date().getTime().toString();
component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"SUCCESS\",\"status\":\"SUCCESS\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"SUCCESS\",\"status\":\"SUCCESS\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
let response = new ResponseOptions({
body: JSON.stringify(mockData)
});
@@ -357,15 +357,14 @@ describe('TestComponent', () => {
mockBackend.connections.subscribe(
(c: MockConnection) => c.mockRespond(baseResponse)
);
-
+
component.pollTestStatus();
}));
- it('should check error condition on polling where timestamp and test status are not available', inject([MockBackend], (mockBackend: MockBackend) => {
+ it('should execute else part if timeStamp && status && statusReason are false', inject([MockBackend], (mockBackend: MockBackend) => {
component.requestId = new Date().getTime().toString();
component.actionIdentifiers['vnf-id'] = 123456;
- //let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
- let mockData = { "output": { "common-header": { "timestamp": "2018-03-21T14:20:30.910Z", "api-ver": "2.00", "request-id": "1521642030910", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 }, "originator-id": "CDT", "sub-request-id": "1521642030910" }, "status": { "message": "INVALID INPUT PARAMETER - vserver-id", "code": 301 } } };
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
let response = new ResponseOptions({
body: JSON.stringify(mockData)
});
@@ -373,14 +372,15 @@ describe('TestComponent', () => {
mockBackend.connections.subscribe(
(c: MockConnection) => c.mockRespond(baseResponse)
);
-
+
component.pollTestStatus();
}));
- it('should execute else part if timeStamp && status && statusReason are false', inject([MockBackend], (mockBackend: MockBackend) => {
+ it('should check error condition on polling where timestamp and test status are not available', inject([MockBackend], (mockBackend: MockBackend) => {
component.requestId = new Date().getTime().toString();
component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ //let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
+ let mockData={"output":{"common-header":{"timestamp":"2018-03-21T14:20:30.910Z","api-ver":"2.00","request-id":"1521642030910","flags":{"force":"TRUE","mode":"NORMAL","ttl":3600},"originator-id":"CDT","sub-request-id":"1521642030910"},"status":{"message":"INVALID INPUT PARAMETER - vserver-id","code":301}}};
let response = new ResponseOptions({
body: JSON.stringify(mockData)
});
@@ -388,7 +388,7 @@ describe('TestComponent', () => {
mockBackend.connections.subscribe(
(c: MockConnection) => c.mockRespond(baseResponse)
);
-
+
component.pollTestStatus();
}));
@@ -408,7 +408,7 @@ describe('TestComponent', () => {
component.pollTestStatus();
}));
});
-
+
// Test getUrlEndPoint Method
describe('Test getUrlEndPoint Method', () => {
it('Should have getUrlEndPoint method', () => {
@@ -429,6 +429,9 @@ describe('TestComponent', () => {
expect(component.getUrlEndPoint('upgradeprecheck')).toEqual('upgrade-pre-check');
expect(component.getUrlEndPoint('upgradesoftware')).toEqual('upgrade-software');
expect(component.getUrlEndPoint('DeFaultCASE')).toEqual('defaultcase');
+ expect(component.getUrlEndPoint('upgradebackup')).toEqual('upgrad-ebackup');
+ expect(component.getUrlEndPoint('attachvolume')).toEqual('attach-volume');
+ expect(component.getUrlEndPoint('detachvolume')).toEqual('detach-volume');
});
});
-}) \ No newline at end of file
+})
diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts
index dd8871e..18d6541 100644
--- a/src/app/test/test.component.ts
+++ b/src/app/test/test.component.ts
@@ -16,7 +16,6 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
============LICENSE_END============================================
*/
@@ -101,7 +100,7 @@ export class TestComponent implements OnInit {
public pollCounter = 0;
public enableCounterDiv: boolean = false;
public enableDownload: boolean = false;
-
+ private userId = localStorage['userId'];
constructor(private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService, private nService: NotificationsService, private router: Router, private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private httpUtil: HttpUtilService,
private utiltiy: UtilityService, private ngProgress: NgProgress) {
@@ -198,7 +197,6 @@ export class TestComponent implements OnInit {
- console.log('Array data ==' + arrData[0]);
this.vmPayload = [];
this.subPayload = {};
this.vmJson = {};
@@ -333,9 +331,7 @@ export class TestComponent implements OnInit {
}
constructRequest() {
- console.log('payload==' + JSON.stringify(this.payload));
let timeStamp = new Date().toISOString();
- console.log('timestamp==' + timeStamp);
let reqId;
this.requestId = reqId = new Date().getTime().toString();
let data = {
@@ -343,7 +339,7 @@ export class TestComponent implements OnInit {
'common-header': {
'timestamp': timeStamp,
'api-ver': '2.00',
- 'originator-id': 'CDT',
+ 'originator-id': this.userId,
'request-id': this.requestId,
'sub-request-id': this.requestId,
'flags': {
@@ -367,9 +363,9 @@ export class TestComponent implements OnInit {
this.enablePollButton = false;
this.timer = Observable.interval(10000);
this.subscribe = this.timer.subscribe((t) => this.pollTestStatus());
- //console.log('full payload==' + JSON.stringify(this.apiRequest));
this.ngProgress.start();
this.apiRequest = JSON.stringify(this.constructRequest());
+
this.httpUtil.post(
{
url: environment.testVnf + this.getUrlEndPoint(this.action.toLowerCase()), data: this.apiRequest
@@ -405,7 +401,7 @@ export class TestComponent implements OnInit {
'common-header': {
'timestamp': timeStamp,
'api-ver': '2.00',
- 'originator-id': 'CDT',
+ 'originator-id': this.userId,
'request-id': reqId,
'sub-request-id': reqId,
'flags': {
@@ -415,7 +411,9 @@ export class TestComponent implements OnInit {
}
},
'action': 'ActionStatus',
- 'action-identifiers': this.actionIdentifiers,
+ 'action-identifiers': {
+ 'vnf-id' : this.actionIdentifiers['vnf-id']
+ },
'payload': '{"request-id":' + this.requestId + '}'
}
};
@@ -509,6 +507,12 @@ export class TestComponent implements OnInit {
return 'upgrade-pre-check';
case 'upgradesoftware':
return 'upgrade-software';
+ case 'upgradebackup':
+ return 'upgrade-backup';
+ case 'attachvolume':
+ return 'attach-volume';
+ case 'detachvolume':
+ return 'detach-volume';
default:
return action.toLowerCase();
}
diff --git a/src/app/vnfs/LoginGuardService/Login-guard-service.ts b/src/app/vnfs/LoginGuardService/Login-guard-service.ts
index 2c834a8..35640d0 100644
--- a/src/app/vnfs/LoginGuardService/Login-guard-service.ts
+++ b/src/app/vnfs/LoginGuardService/Login-guard-service.ts
@@ -16,18 +16,14 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
-import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
-
-import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
-
+import {Injectable} from '@angular/core';
import {MappingEditorService} from '../../shared/services/mapping-editor.service';
+import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
@Injectable()
export class LoginGuardService implements CanActivate {
@@ -39,11 +35,11 @@ export class LoginGuardService implements CanActivate {
let userId = localStorage['userId'];
if (userId != null && userId != undefined && userId != '') {
- this.router.navigate(['/vnfs/list']);
- return false;
- } else {
return true;
+ } else {
+ this.router.navigate(['/vnfs/login'],{ queryParams: { returnUrl: state.url }});
+ return false;
}
}
-} \ No newline at end of file
+}
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
index dfb665e..188fe81 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.ts
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
@@ -16,36 +16,38 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
import {Component, OnInit} from '@angular/core';
-import {Router} from '@angular/router';
+
+import { ActivatedRoute } from '@angular/router';
import {EmitterService} from '../../shared/services/emitter.service';
+import {Router} from '@angular/router';
import {UtilityService} from '../../shared/services/utilityService/utility.service';
@Component({selector: 'app-mvnfs-form', templateUrl: './userlogin-form.component.html', styleUrls: ['./userlogin-form.component.css']})
export class userloginFormComponent implements OnInit {
userId: string = '';
+ returnUrl:string
- constructor(private router: Router, private utiltiy: UtilityService) {
+ constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute
+ ) {
}
ngOnInit() {
+ this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/home';
}
+
getData() {
localStorage['userId'] = this.userId;
localStorage['apiToken'] = this.utiltiy.randomId();
EmitterService
.get('userLogin')
.emit(this.userId);
- this
- .router
- .navigate(['vnfs', 'list']);
+ this.router.navigateByUrl(this.returnUrl);
}
}
diff --git a/src/app/vnfs/vnf.routing.ts b/src/app/vnfs/vnf.routing.ts
index b12530d..fa4e517 100644
--- a/src/app/vnfs/vnf.routing.ts
+++ b/src/app/vnfs/vnf.routing.ts
@@ -16,26 +16,24 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
-import { GoldenConfigurationHolderComponent, } from './build-artifacts/template-holder/template-holder.component';
-import { MyvnfsComponent } from './myvnfs/myvnfs.component';
-import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
-import { ReferenceDataformComponent } from './build-artifacts/reference-dataform/reference-dataform.component';
+
+import { BuildDesignComponent } from './build-artifacts/build-artifacts.component';
import { GoldenConfigurationComponent } from './build-artifacts/template-holder/template-configuration/template-configuration.component';
+import { GoldenConfigurationHolderComponent, } from './build-artifacts/template-holder/template-holder.component';
import { GoldenConfigurationMappingComponent } from './build-artifacts/template-holder/param-name-value/param-name-value.component';
+import { LoginGuardService } from './LoginGuardService/Login-guard-service';
+import { MyvnfsComponent } from './myvnfs/myvnfs.component';
+import { NgModule } from '@angular/core';
import { ParameterComponent } from './build-artifacts/parameter-definitions/parameter.component';
import { ParameterHolderComponent } from './build-artifacts/parameter-holder/parameter-holder.component';
+import { ReferenceDataHolderComponent } from './build-artifacts/reference-data-holder/reference-data-holder.component';
+import { ReferenceDataformComponent } from './build-artifacts/reference-dataform/reference-dataform.component';
import { VnfsComponent } from './vnfs/vnfs.component';
-import { BuildDesignComponent } from './build-artifacts/build-artifacts.component';
import { userloginFormComponent } from './userlogin-form/userlogin-form.component';
-import { LoginGuardService } from './LoginGuardService/Login-guard-service';
-import { ReferenceDataHolderComponent } from './build-artifacts/reference-data-holder/reference-data-holder.component';
-
const routes: Routes = [
{
@@ -43,19 +41,21 @@ const routes: Routes = [
component: VnfsComponent,
children: [
{
- path: '',
+ path: 'login',
component: userloginFormComponent,
- canActivate: [LoginGuardService],
+
}, {
path: 'list',
- component: MyvnfsComponent
+ component: MyvnfsComponent,
+ canActivate: [LoginGuardService],
},
{
path: 'design',
component: BuildDesignComponent,
+
children: [
{
path: 'references',
@@ -117,8 +117,13 @@ const routes: Routes = [
]
- },
+ }
]
+ }, {
+ path: '',
+ redirectTo: 'list',
+ pathMatch: 'full'
+
}
]
}
@@ -129,4 +134,4 @@ const routes: Routes = [
exports: [RouterModule]
})
export class VnfRoutingModule {
-} \ No newline at end of file
+}