I have a .feature file that will receive argument from another feature file as __arg to generate token for oAuth
Given url urlRefreshToken
Given def json = __arg
And header Content-Type = 'application/json; charset=utf-8'
And request json
* header Authorization = 'Bearer' + __arg.refresh_token
When method POST
Then status 200
* def bearer = 'Bearer ' + response.access_token
I am trying to centralise the token generation for only one time on karate-config.js
. However I cannot seem to be able to use karate.callSingle() with passed parameters.
I use the feature file to generate token on other feature files as:
* def getToken = call read('classpath:features/Utils/GetToken.feature') refreshTokenRaymond
* header Authorization = getToken.bearer
I am trying to invoke the feature file for generating token on karate-config.js
to no avail. I tried to pass in the additional parameter like this on karate-config.js
:
var config = {
baseUrl: 'url',
urlRefreshToken: 'url',
refreshToken: '{refreshToken: refreshToken}'
};
var token = karate.callSingle('classpath:features/Utils/GetToken.feature', [config, config.refreshToken])
I wonder if it is possible to pass multiple parameter to karate.callSingle()
called from karate-config.js
?
Any help will be greatly appreciated. Thanks!