Change Authorization Profiles

Applies to ReadyAPI 3.5, last modified on January 19, 2021

You can use Groovy scripts to change the authorization profile and credentials that will be used for a request.

Where To Use

There are several ways to run this script:

Example

For Basic authorization

Groovy

import com.eviware.soapui.config.AuthEntryTypeConfig

def request = testRunner.testCase.getTestStepByName("Name of the Request").getHttpRequest()
request.setSelectedAuthProfile(AuthEntryTypeConfig.BASIC.toString())
request.username = "NewUserName"
request.password = "NewPassword"
request.domain = "NewDomain"

For a custom authorization profile

Groovy

import com.eviware.soapui.config.AuthEntryTypeConfig

def authProfileName = "Name of your profile";
def project = testRunner.getTestCase().getTestSuite().getProject();
def authProfile = project.getAuthRepository().getEntry(authProfileName);
authProfile.setUsername("newUsername");
authProfile.setPassword("newPassword");
authProfile.setDomain("newDomain");

//Set to true for pre-emptive authentication
//Set to false for using global preference
authProfile.setPreemptive(true);

def step = testRunner.testCase.getTestStepByName("Name of your request").getHttpRequest();
step.setSelectedAuthProfile(authProfileName);

See Also

Authentication
Groovy Scripts
Scripting

Highlight search results