You may have already figured it out, but it looks like each value has a unique identifier you could use. If you need to reference each one by name, you could do something like this:
def headers = testRunner.testCase.testSteps["REST Request)"].testRequest.response.responseHeaders
headers.each {
if (it.getKey() == 'Set-Cookie') { // assuming this is a map
def valueParts = it.getValue().split('=') // Split the value on the equals
testRunner.testCase.setPropertyValue(valueParts[0], it.getValue())
}
}
// This would get you the following test case properties:
testCase.getPropertyValue('returnurl') // returnurl=9d97d277ed656a2...
testCase.getPropertyValue('authtype') // authtype=72b76f4f5cf...
testCase.getPropertyValue('state') // state=81ef1f0ff48fcd...
testCase.getPropertyValue('nonce') // nonce=7511a89aaacda...
Or, if you just need them all and don't need to reference each one by name, you could just throw them in a list:
import groovy.json.*
def headers = testRunner.testCase.testSteps["REST Request)"].testRequest.response.responseHeaders
def cookieList = []
headers.each {
if (it.getKey() == 'Set-Cookie') { // assuming this is a map
cookieList.add(it.getValue())
}
}
// This would get you: ["returnurl=9d97d277ed656a2", "authtype=72b76f4f5cf", "state=81ef1f0ff48fcd", "nonce=7511a89aaacda"]
// Store as test case property -- can only store String, that's why we serialize the List to JSON
testRunner.testCase.setPropertyValue("cookieList", new JsonBuilder(cookieList).toString())
// To use in another Groovy script
String cookieListStr = testRunner.testCase.getPropertyValue("cookieList")
def cookieList = new JsonSlurper().parseText(cookieListStr) // Deserialize JSON back into a List