bernhardn
10 years agoOccasional Contributor
setting proxy from groovy in SoapUI 5.0.0
Hi all
I am trying to dynamically change the proxy settings (enable or disable) from a groovy script that runs a number of test steps (SOAP requests dont use proxy, REST steps need to go via a proxy).
Found some code on the web and it sounded as if this is supposed to be possible but I cant make it work.
Below is my code. Note that I start with proxy enabled (preferences/proxy settings is 'Manual' and menu button is green).
The first step is a SOAP request and is not supposed to use the proxy.
The first log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" ) does return 'true' - as expected.
The second log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" ) does return 'false' - also as expected.
However, the next request is still going to the proxy!!!
When I check the preferences/proxy settings they are set to None, but the menu icon is still green.
Only once I click the OK button on the preferences/proxy settings, the menu icon changes to red and the proxy is disabled.
Do I miss a step in my groovy script, like saving the settings change or such like?
Kind regards, and many thanks for any ideas.
Bernhard
PS.
no, using ProxyUtils.setProxyEnabled(false) instead doesnt do it either.
if (testStep.config.type == "restrequest"
&& currentTestSuite.getPropertyValue("TestsFileName") == 'xxx.xls'
&& endPoints.getCell(1,0).getContents().toUpperCase().subSequence(0,5) == 'QUAL')
{
if (loglevel=="DEBUG") log.info('enable proxy');
SoapUI.settings.setString(ProxySettings.ENABLE_PROXY,"true" );
// ProxyUtils.setProxyEnabled(true);
}
else
{
if (loglevel=="DEBUG") log.info('disable proxy');
log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" )
SoapUI.settings.setString(ProxySettings.ENABLE_PROXY,"false");
log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" )
};
try {
tsResult = testRunner.runTestStepByName(testStep.getName());
timetaken = tsResult.getTimeTaken();
I am trying to dynamically change the proxy settings (enable or disable) from a groovy script that runs a number of test steps (SOAP requests dont use proxy, REST steps need to go via a proxy).
Found some code on the web and it sounded as if this is supposed to be possible but I cant make it work.
Below is my code. Note that I start with proxy enabled (preferences/proxy settings is 'Manual' and menu button is green).
The first step is a SOAP request and is not supposed to use the proxy.
The first log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" ) does return 'true' - as expected.
The second log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" ) does return 'false' - also as expected.
However, the next request is still going to the proxy!!!
When I check the preferences/proxy settings they are set to None, but the menu icon is still green.
Only once I click the OK button on the preferences/proxy settings, the menu icon changes to red and the proxy is disabled.
Do I miss a step in my groovy script, like saving the settings change or such like?
Kind regards, and many thanks for any ideas.
Bernhard
PS.
no, using ProxyUtils.setProxyEnabled(false) instead doesnt do it either.
if (testStep.config.type == "restrequest"
&& currentTestSuite.getPropertyValue("TestsFileName") == 'xxx.xls'
&& endPoints.getCell(1,0).getContents().toUpperCase().subSequence(0,5) == 'QUAL')
{
if (loglevel=="DEBUG") log.info('enable proxy');
SoapUI.settings.setString(ProxySettings.ENABLE_PROXY,"true" );
// ProxyUtils.setProxyEnabled(true);
}
else
{
if (loglevel=="DEBUG") log.info('disable proxy');
log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" )
SoapUI.settings.setString(ProxySettings.ENABLE_PROXY,"false");
log.info SoapUI.settings.getString( ProxySettings.ENABLE_PROXY, "No Value set" )
};
try {
tsResult = testRunner.runTestStepByName(testStep.getName());
timetaken = tsResult.getTimeTaken();