Cookies 使用Gatling工具管理jsessionid cookie

Cookies 使用Gatling工具管理jsessionid cookie,cookies,gatling,Cookies,Gatling,我有一个关于“加特林”(Gatling)模拟的问题,该模拟涉及登录java webapp 我设置了下面的模拟,我惊讶地注意到,即使我没有明确地检索和设置请求之间的JSESSIONIDcookie,它仍然可以工作 我本以为此处带有//AUTHENTICATED请求的get注释会失败。 有人能提供见解吗 class SigninAndAct extends Simulation { val baseURL = "http://localhost:8080" val httpConf

我有一个关于“加特林”(Gatling)模拟的问题,该模拟涉及登录java webapp

我设置了下面的模拟,我惊讶地注意到,即使我没有明确地检索和设置请求之间的
JSESSIONID
cookie,它仍然可以工作

我本以为此处带有
//AUTHENTICATED请求的get注释会失败。

有人能提供见解吗

class SigninAndAct extends Simulation {

    val baseURL = "http://localhost:8080"
    val httpConf = httpConfig
            .baseURL(baseURL)
            .acceptHeader("*/*")
            .acceptEncodingHeader("gzip, deflate")
            .acceptLanguageHeader("fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3")
            .connection("keep-alive")
            .userAgentHeader("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0")


    val headers_1 = Map(
            "Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"""
    )

    val headers_2 = Map(
            "Accept" -> """text/css,*/*;q=0.1"""
    )

    val headers_31 = Map(
            "Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""",
            "Content-Type" -> """application/x-www-form-urlencoded"""
    )


    val scn = scenario("Signin-scn")
                .exec(http("open-signin-page")
                    .get("/bignibou/signin")
                    .headers(headers_1)
                    .check(regex("""<input type="hidden" name="_csrf" value="(.*)" />""")
                    .saveAs("_csrf")))
                .exec(http("signin")
                    .post("/bignibou/signin")
                    .headers(headers_1)
                    .param("_csrf", "${_csrf}")
                    .param("username","balteo@yahoo.fr")
                    .param("password","------")
                    .check(currentLocation.is(baseURL+"/bignibou/dashboard")))
                .exec(http("open-edit-add-page")
                     .get("/bignibou/advertisement/childminder/edit/32768")//AUTHENTICATED REQUEST HERE
                     .headers(headers_1)
                     .check(currentLocation.is(baseURL+"/bignibou/advertisement/childminder/edit/32768")))

    setUp(scn.users(1).protocolConfig(httpConf))
}
类符号NANDACT扩展模拟{
val baseURL=”http://localhost:8080"
val httpConf=httpConfig
.baseURL(baseURL)
.acceptHeader(“*/*”)
.acceptEncodingHeader(“gzip,deflate”)
.acceptLanguageHeader(“fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3”)
.连接(“保持活动”)
.userAgentHeader(“Mozilla/5.0(X11;Ubuntu;Linux x86_64;rv:28.0)Gecko/20100101 Firefox/28.0”)
val headers_1=Map(
接受“->”text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
)
val headers_2=映射(
接受“->”文本/css,*/*;q=0.1“”
)
val headers_31=映射(
“接受”->“text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”“”,
“内容类型”->“应用程序/x-www-form-urlencoded”“”
)
val scn=场景(“登录scn”)
.exec(http(“打开登录页”)
.get(“/bignibou/sign”)
.headers(headers_1)
.检查(正则表达式(“”)
.saveAs(“\u csrf”))
.exec(http(“登录”)
.post(“/bignibou/signin”)
.headers(headers_1)
.param(“${u csrf}”)
.param(“用户名”balteo@yahoo.fr")
.param(“密码”、“----”)
.check(currentLocation.is(baseURL+“/bignibou/dashboard”))
.exec(http(“打开编辑添加页面”)
.get(“/bignibou/advision/childminder/edit/32768”)//此处的身份验证请求
.headers(headers_1)
.check(currentLocation.is(baseURL+“/bignibou/advision/childminder/edit/32768”))
设置(scn.users(1.protocolConfig(httpConf))
}

那是因为盖特林帮你处理这件事。它会自动将它们存储在用户会话中,并将它们传递到下一个请求。

来自Gatling的非常整洁!非常感谢。但这是否有文件记录?