Change Authorization Profiles

Applies to ReadyAPI 3.56, last modified on November 21, 2024

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 1 – 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"

Example 2 – 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 Scripting Samples
Scripting

Highlight search results