You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Execute cypress tests for a connector having multiple credentials which can be used for different scenarios (one api key for cards, another for bank redirects and etc.,).
Implementation
Introduce new format for creds.json
creds.json should include both the formats. if a connector requires us passing multiple credentials, then that connector api key object should include multiple connector_account_details object all named under a generic name connector_<number> where number is an integer.
Within connector.js, introduce new object called as Configs alongside to Request and Response where user can define flags to achieve granular control over what test is being run.
An example implementation given below for reference:
getCustomExchange({Configs: {TRIGGER_SKIP: true,// skips redirection flow from running. takes in a booleanDELAY: {STATUS: true,// flag to turn delay feature on or off. takes in a booleanTIMEOUT: 5000,// timeout in milliseconds},CONNECTOR_CREDENTIAL: connector_1/connector_2// flag to route tests to a specific profile// etc.,},Requst: {},Response: {}}),
Modify getValueByKey function in Utils.js
Validate if connector_account_details dot exist within <connector> object in creds.
If it does not, start a loop and see if connector_account_details exist within every object. If true, return the connector_account_details while setting an object as a Cypress environment flag (MULTIPLE_CONNECTORS) with status true and length. If any validation fails, directly return the object (data[key]).
An example implementation given below for reference:
if(data&&typeofdata==="object"&&keyindata){// Connector object has multiple keysif(typeofdata[key].connector_account_details==="undefined"){constkeys=Object.keys(data[key]);for(leti=0;i<keys.length;i++){constcurrentItem=data[key][keys[i]];if(currentItem.hasOwnProperty("connector_account_details")){Cypress.env("MULTIPLE_CONNECTORS",{status: true,count: keys.length,});returncurrentItem;}}}returndata[key];}else{returnnull;}
Add a new test to MCA create call
If MULTIPLE_CONNECTORS.status is TRUE. Check MULTIPLE_CONNECTORS.count and create profile and mca beneath that profile based on the number of count.
An example of possible implementation given below for reference:
if(Cypress.env("MULTIPLE_CONNECTORS")?.status){for(leti=0;i<Cypress.env("MULTIPLE_CONNECTORS").count;i++){cy.createBusinessProfileTest(createBusinessProfileBody,globalState,"profile"+i// new optional fields);cy.createConnectorCallTest("payment_processor",createConnectorBody,payment_methods_enabled,globalState,"profile"+i,// new optional fields"merchantConnector"+i// new optional fields);}}
Store these created profile_ids and mcas in globalState for future usage.
Pass CONNECTOR_CREDENTIAL value as connector_1 or connector_2 in <connector>.js
In commands.js, execute these configs before a request has been made. execute here means to make these configs work.
Preferably, make this execution of configs a function and pass the values accordingly along with trace to find from where the function has been called.
Limitations
Cypress cannot call itself unless a wrapper around Cypress is written (Rustpress?)
This stops us from running the entire test suite against every credentials
One possible work around for this is to have multiple keys (cybersource_1, cybersource_2) but this will result in a lot of confusion
Current implementation requires the user to mandatorily pass a CONNECTOR_CREDENTIAL config to pass a different profileId
Hence, the tests will only run once but, specific tests like incremental auth will be forced to run against different credential
00025-IncrementalAuth.cy.js can be stopped from execution based on MULTIPLE_CONNECTORS environment variable as it is set during run time and the file is read asynchronously when the execution starts (to address this, we will have to make a function call to see if it is set during run time and it is, then skip)
The text was updated successfully, but these errors were encountered:
Requirement
Execute cypress tests for a connector having multiple credentials which can be used for different scenarios (one api key for
cards
, another forbank redirects
and etc.,).Implementation
Introduce new format for
creds.json
creds.json
should include both the formats. if a connector requires us passing multiple credentials, then that connector api key object should include multipleconnector_account_details
object all named under a generic nameconnector_<number>
wherenumber
is aninteger
.Refer example given below for more clarity:
Introduce new
object
(Configs
) forconnector.js
Within
connector.js
, introduce new object called asConfigs
alongside toRequest
andResponse
where user can defineflags
to achieve granular control over what test is being run.An example implementation given below for reference:
Modify
getValueByKey
function inUtils.js
Validate if
connector_account_details
dot exist within<connector>
object in creds.If it does not, start a loop and see if
connector_account_details
exist within every object. If true, return theconnector_account_details
while setting an object as a Cypress environment flag (MULTIPLE_CONNECTORS
) with statustrue
and length. If any validation fails, directly return the object (data[key]
).An example implementation given below for reference:
Add a new test to MCA create call
If
MULTIPLE_CONNECTORS.status
isTRUE
. CheckMULTIPLE_CONNECTORS.count
and createprofile
andmca
beneath thatprofile
based on the number ofcount
.An example of possible implementation given below for reference:
Store these created
profile_id
s andmca
s inglobalState
for future usage.Pass
CONNECTOR_CREDENTIAL
value asconnector_1
orconnector_2
in<connector>.js
In
commands.js
,execute
these configs before arequest
has been made.execute
here means to make these configs work.Preferably, make this execution of configs a function and pass the values accordingly along with trace to find from where the function has been called.
Limitations
Rustpress
?)cybersource_1
,cybersource_2
) but this will result in a lot of confusionCONNECTOR_CREDENTIAL
config to pass a differentprofileId
incremental auth
will be forced to run against different credential00025-IncrementalAuth.cy.js
can be stopped from execution based onMULTIPLE_CONNECTORS
environment variable as it is set during run time and the file is read asynchronously when the execution starts (to address this, we will have to make a function call to see if it is set during run time and it is, then skip)The text was updated successfully, but these errors were encountered: