i have a project that is using Authorization OAuth 2.0 for all the services in the application in dev and stage environments (different Access Token URLs).
i am able to generate the tokens for each environment but is there a way to automate the request to use the correct token based on the Environment Vriables?
Solved! Go to Solution.
I was playing around with the environment function a while back and @nmrao mentioned something pretty handy (he gets the cred for this idea) which i've continued to use for all projects since.
I have a .properties file (saved at project level) that is specific to each environment that has all the parameters for that environment. It contains full URLs, database settings, etc., (static environment parameters) as well as placeholder properties (corresponding to the dynamic environment parameters, e.g. GUIDs) that are environment specific.
Before executing the project i load in the relevant environments project level .properties file. This repoints all the REST/SOAP/JDBC requests/teststeps to the appropriate environment (setting the static parameters and creating property names for the dynamic parameters.
I also have a setup testsuite (first test suite in project) that contains steps to generate any of the dynamic parameter properties that are saved at the project level.
Just to reiterate. I have 1 properties file for each environment and load it in before execution.
@richie i appreciate your reply but the issue here is not how to get URLs or DBs specific to each environment, I have no problem loading those values, i actually built a groovy script that gets DB URLs based on which environment we are running the test against. but i am trying to do the same to get Access Token value generated from authorization call in "Auth & Security" based on the environment.
Ah...sorry. my bad. I misunderstood.
Someone else posted this very question about 3 weeks ago or less.
Im typing this out on my phone so its a bit awkward to search but if you do a search for other posts relating to OAuth v2.0 you should be able to find the post. However, im not sure if the post was successfully answered....i dont think it was as i wouldve taken note of the answer cos id like to use it in the future myself.
Have a search for the post and perhaps one of the other forum members who are better scripters than i might be able to help, but in the meantime i think it might be worth submitting a support request to Smartbear to determine the property the token value is actually saved against within the OAuth v2.0 function.
Thats all i got on this im afraid, but if you do get an answer id be very interested!
the answer was hidden in Auth Manager window
basically, you chose the environment first then you pick the correct token using Auth Manager for each test case for that environment and you save and you then pick the next environment and you do the same using the other token corresponding to that other environment