Hello,
I was wondering if anyone could help with a problem I’ve been having.
Our application which uses oauth2, needs a header cookie passed in to perform stuff such as get/post/delete requests. I’m able to get the cookie via postman.
The cookie is in 3 parts
".AspNetCore.Cookies=XXX; "
“.AspNetCore.CookiesC1=YYY;”
“.AspNetCore.CookiesC2=ZZZ;”
In my API testing suite, using unirest, something as simple as this works:
String adminUserCookie = “.AspNetCore.Cookies=XXX; .AspNetCore.CookiesC1=YYY; .AspNetCore.CookiesC2=ZZZ”;
@Test
public void admin_get_records() {
Unirest.config().reset();
Unirest.config()
.enableCookieManagement(false);
HttpResponse response = Unirest.get(“https://myurl.com/record/index”)
.header(“Cookie”, adminUserCookie)
.asString();
assertEquals(200, response.getStatus());
}
The problem is with Gatling, I can’t get it to work. I left the code at this after trying multiple things:
def addCookie1() :ChainBuilder = {
exec(addCookie(Cookie(".AspNetCore.Cookies", “XXX”)))
}
def addCookie2() :ChainBuilder = {
exec(addCookie(Cookie(".AspNetCore.CookiesC1", “YYY”)))
}
def addCookie3() :ChainBuilder = {
exec(addCookie(Cookie(".AspNetCore.CookiesC2", “YYY”)))
}
def adminGetRecords() :ChainBuilder = {
exec(http(“Admin Get Records”)
.get(“https://myurl.com/record/index”)
.check(status.is(200))
}
Then under the scenario I built the chain. I tried adding the cookie in with the get request as well, but was obviously doing that wrong. Any help would be really appreciated.
Many Thanks,
David