我有同样的问题,但我没有307,只有302.我想解决方案是一样的.我做的是:
>使用redirects()停止第一次调用时重定向.跟随(false)
>从第一个重定向捕获URL
>拨打另一个电话来关注重定向
Response resp1 =
given().
contentType(ContentType.URLENC).
body("AUTH_TOKEN=&j_username=" + encodedUsername + "&j_password=" + password + "&userName=&AUTH_TOKEN=").
redirects().follow(false).
expect().
statusCode(302).
when().
post("/authenticate/j_spring_security_check");
String headerLocationValue = resp1.getHeader("Location");
Response resp2 =
given().
cookie(resp1.getDetailedCookie("JSESSIONID")).
expect().
statusCode(200).
when().
get(headerLocationValue);