Forum Discussion
Unibet_Support
12 years agoContributor
My latest findings.
Seems there is a bugg in the cookie handling after all.
I login and get a sessioncookie.
I ask my internal security server to give me a token (to be logged in for all tests)
I then get redirected, the security server set a secret cookie based on my session cookie.
Several redirects takes place and in these both cookies needs to exists.
Soapui never sets the second 'secret cookie' (the webbrowsers do, tested firefox & chrome).
So I came up with some groovy scripts to manually handle this.
Here is a example script on how to handle cookie manager and create cookies:
----------------------
import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport
import org.apache.http.impl.cookie.BasicClientCookie
//the http client -- org.apache.http.impl.client.DefaultHttpClient
def myClient = HttpClientSupport.getHttpClient()
//clients cookie store -- org.apache.http.client interface CookieStore
def myStore = myClient.getCookieStore()
// to remove all cookies
//myStore.clear()
// Get list of all cookies
def cookieList = myStore.getCookies()
//log.info "nbr---of---cookies : " + cookieList.size()
def my_old_cookie
//find my old cookie that I want to copy value from
for (i in cookieList) { // i is a cookie
if (i.getName().contains("my_old_cookie")) {
my_old_cookie = i
}
}
//Create new cookie
def my_new_cookie = new BasicClientCookie("my_new_cookie",my_old_cookie.getValue())
my_new_cookie.setDomain(".myurl.com")
my_new_cookie.setPath("/mypath")
my_new_cookie.setSecure(true)
//add the created new cooki to the cookiemanager
myStore.addCookie(my_new_cookie)
--------------------------------------------------
Regards
/Anders
Seems there is a bugg in the cookie handling after all.
I login and get a sessioncookie.
I ask my internal security server to give me a token (to be logged in for all tests)
I then get redirected, the security server set a secret cookie based on my session cookie.
Several redirects takes place and in these both cookies needs to exists.
Soapui never sets the second 'secret cookie' (the webbrowsers do, tested firefox & chrome).
So I came up with some groovy scripts to manually handle this.
Here is a example script on how to handle cookie manager and create cookies:
----------------------
import com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport
import org.apache.http.impl.cookie.BasicClientCookie
//the http client -- org.apache.http.impl.client.DefaultHttpClient
def myClient = HttpClientSupport.getHttpClient()
//clients cookie store -- org.apache.http.client interface CookieStore
def myStore = myClient.getCookieStore()
// to remove all cookies
//myStore.clear()
// Get list of all cookies
def cookieList = myStore.getCookies()
//log.info "nbr---of---cookies : " + cookieList.size()
def my_old_cookie
//find my old cookie that I want to copy value from
for (i in cookieList) { // i is a cookie
if (i.getName().contains("my_old_cookie")) {
my_old_cookie = i
}
}
//Create new cookie
def my_new_cookie = new BasicClientCookie("my_new_cookie",my_old_cookie.getValue())
my_new_cookie.setDomain(".myurl.com")
my_new_cookie.setPath("/mypath")
my_new_cookie.setSecure(true)
//add the created new cooki to the cookiemanager
myStore.addCookie(my_new_cookie)
--------------------------------------------------
Regards
/Anders
- swee9 years agoNew Contributor
It is great stuff although it was years ago.
But the returned size is 0
- nmrao9 years agoChampion Level 3Will return the count if there are any, zero otherwise.
If you have further queries, suggest you to create a new thread.- fgvieira7 years agoContributor
Hey, a little bit of time. But could you help me with this step:
1) Login to my test site, so that Im logged in in my browser. not being able to do this.. Could somebody help?
Related Content
- 2 months agoStoplight
- 6 years agoAndyTGardner
- 2 years agoEgg
- 4 years agoryan_perneel
Recent Discussions
- 22 hours agoKay