Reputation: 25039
I have created a project with a bunch of test steps of type HTTP Request
. Each http request uses Basic Authorization
. When I specify username/password values in Auth
request tab as show in the image below, all works fine.
How to keep these
settings in a single place per a project
and so that do not have to change for each request if required to change the credentials?
I tried property expansion feature, and it doesn't work in Auth
tab. UPDATE #3: It works!
Actually I have a solution: project file is a readable XML, so it is easy to replace username/password values (or service URL... everything) in external text editor. Hope for a better way.
UPDATE #1: Accessible authorization types for a HTTP request:
UPDATE #2: Free SoapUI 5.2.1 is used.
Upvotes: 3
Views: 1570
Reputation: 21389
Your are right. It would be very easy for maintenance of the SoapUI
project if the properties are used.
In your case, use of project level custom properties
would be appropriate as per the need.
You could do below to achieve the same:
${#Project#USERNAME}, ${#Project#PASSOCDE}
respectively. This will be one time effort. You can see in screen shot below that the response on the right side when the request is sent after using property expansion
for authorization.
Note that you might notice there is a difference in the screen shot when compared with your for Authorization, because of the SoapUI
version is 4.5.1. However, that should not be any cause of concern.
Once the changes are done, save the project. Now onwards, it will be single place
to just modify user credentials. Of course, you can also change these values from xml file as well like you mentioned.
Apart from the above, it is even possible to override the project property values without even modifying in the soapui-project xml file if you run the SoapUI project from command prompt using SOAPUI_HOME/bin/testrunner.bat or .sh
utility, with the help of -P
option, as mentioned below.
cmd > cd %SOAPUI_HOME%\bin
cmd > testrunner.bat -PUSERNAME=user1 -PPASSCODE=user1passcode -R"Project Report" c:\projects\my-soapui-project.xml
For complete command-line options to run soaui project, please visit here.
UPDATE: Looks there is confusion cased because of SoapUI 4.5.1 screen shot. But the above works in SoapUI-5.x version as well.
Make sure you have set the
File -> Preferences -> HTTP Settings -> Authenticate Preemptively
(check box)is checked (adds authentication information to out going request) and save the preferences.
Below is specific for SoapUI-5.x
setting.
In the Authorization -> Basic
[as you mentioned in the screen shot], set the property expansion as mentioned above for credentials. Also, Pre-emptive auth: Use global preference
radio checked.
Upvotes: 3