Cookie modification in Gatling 2

Hi
I encounter a problem with Gatling’s automatic cookie manager.
it appears that if you send post request to for example "https://test.login.com/Login.php?param1=value1&param2=value2 (with some post data) it stores it in CookieJar with Path value /Login.php
but to make my scenario work i need them to be on “/”, because otherwise they are not included in request to another php service on the same domain.
i’m trying to do something like this

.exec( session => {
session(“gatling.http.cookies”).as[CookieJar].get(URI.create("//extdev2-login.extdev.ptec/Login.php")).map(cookie =>
{ val newcookie = new Cookie(session => cookie.getDomain,
session => cookie.getName,session => cookie.getValue,"/")
println("<----------------> " + newcookie.name.toString() )
//addCookies(“https://extdev2-login.extdev.ptec”, newcookie)
val jar = session(“gatling.http.cookies”).as[CookieJar].add(URI.create( “https://extdev2-login.extdev.ptec/”), List( new com.ning.http.client.Cookie(newcookie.domain.toString(), newcookie.name.toString(), newcookie.value.toString(), “/”, -1, true)))
session.set(“gatling.http.cookies”, jar )
})
new Success(session)
}
)

but it doesnt work.

Please assist, because i am newbie both in scala and in gatling tool

i have also tried and it does not add cookie

.exec( session => {
session(“gatling.http.cookies”).as[CookieJar].get(URI.create("//extdev2-login.extdev.ptec/Login.php")).map(cookie =>
{ val newcookie = new Cookie(session => cookie.getDomain,
session => cookie.getName,session => cookie.getValue,"/")
addCookies(“https://extdev2-login.extdev.ptec”, newcookie)

})
new Success(session)
}
)

.exec( session => {
session(“gatling.http.cookies”).as[CookieJar].get(URI.create("//extdev2-login.extdev.ptec/Login.php")).map(cookie =>
{ val newcookie = new Cookie(session => cookie.getDomain,
session => cookie.getName,session => cookie.getValue,"/")
CookieHandling.storeCookies(session, URI.create( “https://extdev2-login.extdev.ptec/”), List( new com.ning.http.client.Cookie(newcookie.domain.toString(), newcookie.name.toString(), newcookie.value.toString(), “/”, -1, true)))
})
new Success(session)
}
)

This is a bug. Will fix.

Fixed in master: https://github.com/excilys/gatling/issues/1301

thank you very much for such a quick fix!

but someone had broken test in master, so i cant build bundle.

PS: or maybe you can tell me where to put my scenarios in the source project. when i run Gatling.scala it keeps telling me that “There is no simulation script. Please check that your scripts are in user-files/simulations”. thanks in advance!

Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 0.308 sec <<< FAILURE!
console summary progress bar should::handle it correctly when all the users are done(io.gatling.core.result.writer.ConsoleDataWriterSpec) Time elapsed: 0.142 sec <<< FAILURE!
'rg.specs2.reporter.JUnitReporter$$anon$1: '[##########################################################################]100%
is not equal to
‘[##########################################################################]100%’ expected:<…###############]100%[]> but was:<…#]>############]100%[
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$18.apply(ConsoleDataWriterSpec.scala:65)
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$18.apply(ConsoleDataWriterSpec.scala:57)

console summary progress bar should::handle it correctly when all the users are running(io.gatling.core.result.writer.ConsoleDataWriterSpec) Time elapsed: 0.142 sec <<< FAILURE!
'rg.specs2.reporter.JUnitReporter$$anon$1: '[--------------------------------------------------------------------------] 0%
is not equal to
‘[--------------------------------------------------------------------------] 0%’ expected:<…---------------] 0%[]> but was:<…-]>------------] 0%[
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$12.apply(ConsoleDataWriterSpec.scala:54)
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$12.apply(ConsoleDataWriterSpec.scala:47)

console summary progress bar should::handle it correctly when all the users are waiting(io.gatling.core.result.writer.ConsoleDataWriterSpec) Time elapsed: 0.155 sec <<< FAILURE!
'rg.specs2.reporter.JUnitReporter$$anon$1: '[ ] 0%
is not equal to
‘[ ] 0%’ expected:<… ] 0%[]> but was:<… ]> ] 0%[
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$6.apply(ConsoleDataWriterSpec.scala:44)
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$6.apply(ConsoleDataWriterSpec.scala:38)

console summary progress bar should::handle it correctly when there are running and done users(io.gatling.core.result.writer.ConsoleDataWriterSpec) Time elapsed: 0.163 sec <<< FAILURE!
'rg.specs2.reporter.JUnitReporter$$anon$1: '[###################################################################-------] 90%
is not equal to
‘[###################################################################-------] 90%’ expected:<…########-------] 90%[]> but was:<…#]>#####-------] 90%[
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$24.apply(ConsoleDataWriterSpec.scala:76)
at io.gatling.core.result.writer.ConsoleDataWriterSpec$$anonfun$1$$anonfun$apply$24.apply(ConsoleDataWriterSpec.scala:68)

You’re building under Windows, right?
If so, I’ve just pushed a fix.

that is correct. corporate standards ((

thank you very much, but test still fails

By the way, despite my problem was apparently solved with your bugfix, could you please provide some guidelines about the correct way to modify cookies?

2013/7/23 Vova Polishchuk <liberation.fly@gmail.com>