11const { expect } = require ( 'chai' ) ;
22const { MockRuntime } = require ( '@axway/api-builder-test-utils' ) ;
33const getPlugin = require ( '../src' ) ;
4+ const fs = require ( 'fs' ) ;
45
56describe ( 'Flow node CreateCircuitPath query' , ( ) => {
67 let plugin ;
@@ -44,15 +45,15 @@ describe('Flow node CreateCircuitPath query', () => {
4445 } ) ;
4546
4647 it ( 'should error when required parameter params.serviceId is missing' , async ( ) => {
47- const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : 123 } , user : { } , authzConfig : { } } ) ;
48+ const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : 123 } , user : { } , authzConfig : { } , gatewayTopology : { } } ) ;
4849
4950 expect ( value ) . to . be . instanceOf ( Error )
50- . and . to . have . property ( 'message' , 'Missing required parameter: params.serviceID' ) ;
51+ . and . to . have . property ( 'message' , 'Missing required parameter: params.serviceID when not using EMT. ' ) ;
5152 expect ( output ) . to . equal ( 'error' ) ;
5253 } ) ;
5354
5455 it ( 'should succeed with valid parameters as an API-Manager User' , async ( ) => {
55- const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , user : {
56+ const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , gatewayTopology : { } , user : {
5657 apiManager : { role : "user" , organizationName : "Test-Org" } ,
5758 gatewayManager : { }
5859 } , authzConfig : {
@@ -73,7 +74,7 @@ describe('Flow node CreateCircuitPath query', () => {
7374 } ) ;
7475
7576 it ( 'should succeed with valid parameters having API-Manager Org-AuthZ disabled' , async ( ) => {
76- const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , user : {
77+ const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , gatewayTopology : { } , user : {
7778 apiManager : { role : "user" , organizationName : "Test-Org" } ,
7879 gatewayManager : { }
7980 } , authzConfig : {
@@ -93,7 +94,7 @@ describe('Flow node CreateCircuitPath query', () => {
9394 } ) ;
9495
9596 it ( 'should succeed with valid parameters with API-Manager Admin-Role' , async ( ) => {
96- const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , user : {
97+ const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , gatewayTopology : { } , user : {
9798 apiManager : { role : "admin" , organizationName : "Test-Org" } ,
9899 gatewayManager : { }
99100 } , authzConfig : {
@@ -112,5 +113,26 @@ describe('Flow node CreateCircuitPath query', () => {
112113 }
113114 } ) ;
114115 } ) ;
116+
117+ it ( 'should succeed when EMT is enabled' , async ( ) => {
118+ var topology = JSON . parse ( fs . readFileSync ( './test/mockedReplies/emtTopology.json' ) , null ) ;
119+ const { value, output } = await flowNode . createCircuitPathQuery ( { params : { correlationID : "MyCorrelationId" , serviceID : "TestServiceId" } , gatewayTopology : topology , user : {
120+ apiManager : { role : "admin" , organizationName : "Test-Org" } ,
121+ gatewayManager : { }
122+ } , authzConfig : {
123+ apimanagerOrganization : { enabled : true }
124+ } } ) ;
125+
126+ expect ( output ) . to . equal ( 'next' ) ;
127+ expect ( value ) . to . be . a ( 'object' ) ;
128+ expect ( value ) . to . deep . equal ( {
129+ bool : {
130+ must : [
131+ { term : { correlationId : "MyCorrelationId" } } ,
132+ { exists : { field : "transactionSummary.serviceContext" } }
133+ ]
134+ }
135+ } ) ;
136+ } ) ;
115137 } ) ;
116138} ) ;
0 commit comments