Hi,
As everyone can tell I'm not a groovy coder - but if altering the script from my previous messages on this topic appears to be a problem - I have an idea to get around it - i dont know if its possible or not?
the following script is one that I typically use to grab header values.........in this instance, it grabs the first 'Set-Cookie' value (out of the 4 'Set-Cookie' headers) and stores it in the Properties step.
//Takes one of the elements of the response Header
def value = testRunner.testCase.testSteps["GET Cookies"].testRequest.response.responseHeaders["Set-Cookie"]
//Read this value into a parameter - writes the header value into the Properties test step
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils.setPropertyValue("Properties", "Set-Cookie",value[0])
Is there any way to alter the above code so rather than using the 'it' method and some other methods I dont really know how to use - would it be easier to have 4 instances of the 'takes the element from header' and 4 instances of the 'read this value into parameter', but altering the value capture by getting it to search the 'Set-Cookie' value for a specific string and writing out that value to a separate property?
What I mean by this (and this isn't even pseudo code) is something like the following:
//Takes the returnurl 'Set-Cookie' value of the response Header
def returnurlvalue = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["Set-Cookie"] //and some code here equating to a filter where value begins 'returnurl='
//Read this value into a parameter - writes the returnurl header value into the Properties test step
def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils1.setPropertyValue("Properties", "Set-Cookie_returnurl",returnurlvalue[0])
//Takes the authtype'Set-Cookie' value of the response Header
def authtypevalue = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["Set-Cookie"] //and code equating to a filter where value begins 'authtype='
//Read this value into a parameter - writes the authtype header value into the Properties test step
def groovyUtils2 = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils2.setPropertyValue("Properties", "Set-Cookie_authtype", authtypevalue[0])
//Takes the state 'Set-Cookie' value of the response Header
def statevalue = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["Set-Cookie"] //and code equating to a filter where value begins 'state='
//Read this value into a parameter - writes the state header value into the Properties test step
def groovyUtils3 = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils3.setPropertyValue("Properties", "Set-Cookie_state", statevalue[0])
//Takes the nonce 'Set-Cookie' value of the response Header
def noncevalue = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["Set-Cookie"] //and code equating to a filter where value begins 'nonce='
//Read this value into a parameter - writes the nonce header value into the Properties test step
def groovyUtils4 = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils4.setPropertyValue("Properties", "Set-Cookie_nonce",noncevalue[0])
I know it's not pretty or efficient but would it be possible and perhaps easier?
Would anyone know how to add a filter so that when the header attribute value is grabbed - rather than just grabbing the specific header value, the search is filtered (like I've tried to represent above) so that 'Set-Cookie' is captured where value begins 'whatever='?
I know I'm just pulling this out of nowhere here, trying to think of anything that will handle this - out of 500 people that work here - no one knows groovy so they cant help me!
Thanks again,
richie