0

I have the following profile "TPG" for a REST Request already selected and set at the framework level:

Auth Profile enter image description here

How do I modify the username, password, and domain fields; along with changing the choice between the two options for Pre-emptive auth in a standalone groovy script?

Rao
  • 20,781
  • 11
  • 57
  • 77
Jeffrey Lee
  • 51
  • 10

2 Answers2

0

Use property expansion so that value can be picked from custom properties of either test case or test suite or project.

For example using test case level custom properties -

  • create a custom property at test case say USER and define its value
  • similarly, create another property for password say PWD and define its value
  • now set ${#TestCase#USER}, ${#TestCase#PWD} for Username and Password of Auth profile respectively

Use below groovy script to update the values for username and password :

context.testCase.setProperty('USER',newUsernameValue)
context.testCase.setProperty('PWD',newPasswordValue)
Rao
  • 20,781
  • 11
  • 57
  • 77
  • The problem I had with this solution, is that it seems to be modifying the fields for the built in profile NTLM. not the custom profile I had selected prior. – Jeffrey Lee Jan 12 '17 at 19:07
  • Can't understand your comment. – Rao Jan 13 '17 at 00:35
  • Essentially I tried using property expansion to modify the custom properties, but the username, password, and domain for the profile TPG remained the same, with no changes. – Jeffrey Lee Jan 13 '17 at 05:44
  • Can you show the screen shot along with raw request? – Rao Jan 13 '17 at 06:05
  • :Here is my script: http://oi64.tinypic.com/25rm9n9.jpg Here is my raw request, it's just pinging a server: http://tinypic.com/view.php?pic=27wvogj&s=9 – Jeffrey Lee Jan 13 '17 at 23:01
  • some how these images are not being shown, those pages are having just ads. – Rao Jan 14 '17 at 01:12
0

I think that this information is a custom properties in the TestStep.

When you create a testStep with authentication the soapUI generate a singular custom properties(Domain,Username,Password) auth soupUI custom properties

The groovy script for to change this properties will be:

//Print Values Properties
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyList().name;
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyList().value;
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Username");
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Password");
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Domain");
    // SET Properties
    testRunner.testCase.getTestStepByName('NAME_TestStepRequest').setPropertyValue("Username","B");
    testRunner.testCase.getTestStepByName('NAME_TestStepRequest').setPropertyValue("Password","B");
    testRunner.testCase.getTestStepByName('NAME_TestStepRequest').setPropertyValue("Domain","B");
// Get new Values
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Username");
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Password");
    log.info  testRunner.testCase.getTestStepByName('NAME_TestStepRequest').getPropertyValue("Domain");
Roberto Ramos
  • 553
  • 6
  • 16