Forum Discussion

giovanni_favara's avatar
giovanni_favara
Contributor
5 years ago

How to manage different auth profiles per environments in a REST api project

Hello everybody, i have the task to create tests in a Scrum team, which should then run in different environments (Dev, Release, Master). The speciality is, that I have to test REST services in the ...
  • giovanni_favara's avatar
    giovanni_favara
    5 years ago

    Hi New2API ,

    I have now found a way to select the Auth-Profile depending on the environment. Here is my solution.

     

    // prefix from profile name
    def ENV
    ENV = testRunner.testCase.testSuite.project.activeEnvironment.name
    log.info "test environment is >>$ENV<<..."
    // profile name suffix
    def profileSuffix = "OAuth2Azure"
    def authEntry = context.getCurrentStep().testCase.testSuite.project.getAuthRepository().getEntry(ENV + profileSuffix);
    
    log.info authEntry.name

    Thanks for your help.