我有一个Spring Boot应用程序,其中一个控制器根据POST参数重定向到页面。
我正在创建测试用例,希望断言重定向的页面,但我无法从Rest Assured响应中获取重定向的HTML。
我正在创建测试用例,希望断言重定向的页面,但我无法从Rest Assured响应中获取重定向的HTML。
@Test
public void test() throws Exception {
Response response = given()
.param("name", "myName")
.when()
.redirects().follow(true).redirects().max(100)
.post("/myPath"); // it will redirect to another page
// I want to print from <html> to </html> of the redirected page
System.out.println("returned full html /n" + response.getBody().asString());
}
我收到了302的响应码以及响应头中重定向页面的位置。
11:38:03.291 [main] DEBUG org.apache.http.headers - << "Location: http://localhost:8080/myRedirectPage[\r][\n]"
.........
11:38:03.291 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Receiving response: HTTP/1.1 302
11:38:03.291 [main] DEBUG org.apache.http.headers - << HTTP/1.1 302