How to Retrieve SessionAttribute

66 views
Skip to first unread message

leela krishna

unread,
Aug 14, 2017, 11:36:02 AM8/14/17
to Gatling User Group
I'm still unable to parse the session value stored in one request into other. 
I've two http requests
val scn = scenario("Device")
.feed(csvFeeeder)
.exec(http("Auth Header gene)
.post("/auth")
.headers(headers_0)
.formParam("type", "device")
.check(headerRegex("auth","device*").saveAs("authH"))
.check(status.is(401)))

.exec(http("Signed Req")
.post("/auth/oauth")
.headers(Map(
"x-id" -> "${id}",
"x-serial" -> "${serial}",
"Authorization" -> test.dummy))
.formParam("type", "device"))

the test.dummy is a function which converts the saved string "authH" into some format and that converted output needs to be passed to the "Authorozation" header in my second request.  for that purpose I'm using something like this

object test{
def dummy: String = {
val = (Here I need to get the saved authH session attribute)
--- logic to convert into my required format--
return convertedString
}
}


I was unable to get the sessionAttribute there. Is there a way to get the sessionAttribute. Please HELP. I go through the Gatling documentation but could not find any solution

Jay Kelner

unread,
Aug 14, 2017, 3:28:00 PM8/14/17
to Gatling User Group
try "Authorization" -> test.dummy("${authH"})

& let dummy take param
Message has been deleted

leela krishna

unread,
Aug 14, 2017, 3:51:14 PM8/14/17
to Gatling User Group
I tried passing the saved value as method parameter. But still, it did not work. I got 403. I should get a 200

leela krishna

unread,
Aug 15, 2017, 9:11:11 AM8/15/17
to Gatling User Group
I tried to print the parameter value in the test method. But, it just prints ${authH} 

leela krishna

unread,
Aug 15, 2017, 9:23:17 AM8/15/17
to Gatling User Group
Is there anyway, that I can create a sessionAttribute object in my function and get the saved session attribute through that object?

Jay Kelner

unread,
Aug 15, 2017, 2:35:26 PM8/15/17
to Gatling User Group
are you using
"${authH}"

or

s"
${authH}"

or

"""${authH}"""

leela krishna

unread,
Aug 15, 2017, 2:47:31 PM8/15/17
to Gatling User Group
I'm using "${authH}". Anyway I am able to retrieve the session attribute like this
.header("Authorization" , session=>test.dummy(session("authH").as[String]))
Reply all
Reply to author
Forward
0 new messages