15 years ago
Setting a Header value as a property for TestCase
I'm working on a test suite of our SOAP services and the first request is an authentication request whose response contains a SessionToken in its header. That token then must be included in any subsequent request following the authentication.
So far, I get the having to extract it and set it as a TestCase property, but I'm thinking that I'm not doing it correctly. I've seen a few examples, and I can't seem to get it to work the way I want it to.
Authentication Response header:
So, I've setup a groovy script after that test case to do the following:
So that in Request 2, I can set a header value as ${#TestCase#session_token}, but what I'm seeing isn't "2fe90d25-9684-469c-8fc6-6a718c54a813" but rather "[2fe90d25-9684-469c-8fc6-6a718c54a813]", which of course is breaking the remainder of my tests. I'm new to Groovy and SoapUI in general, so any help would be appreciated.
So far, I get the having to extract it and set it as a TestCase property, but I'm thinking that I'm not doing it correctly. I've seen a few examples, and I can't seem to get it to work the way I want it to.
Authentication Response header:
HTTP/1.1 200 OK
Cteonnt-Length: 1964
Content-Type: text/xml; charset=utf-8
Date: Thu, 27 Jan 2011 23:15:23 GMT
Cache-Control: private, max-age=0
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET,ASP.NET
X-AspNet-Version: 2.0.50727
SessionToken: 2fe90d25-9684-469c-8fc6-6a718c54a813
Content-Encoding: gzip
Content-Length: 1139
So, I've setup a groovy script after that test case to do the following:
def session_token = testRunner.testCase.testSteps["Request 1"].testRequest.response.responseHeaders["SessionToken"]
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
groovyUtils.setPropertyValue("Request 2", "session_token", session_token.toString())
So that in Request 2, I can set a header value as ${#TestCase#session_token}, but what I'm seeing isn't "2fe90d25-9684-469c-8fc6-6a718c54a813" but rather "[2fe90d25-9684-469c-8fc6-6a718c54a813]", which of course is breaking the remainder of my tests. I'm new to Groovy and SoapUI in general, so any help would be appreciated.