我需要创建一个AsciiDoc文档,但我不知道在RestAssured中如何使用这是我的代码:
@Test
public void getLogout() throws ApiException {
given()
.standaloneSetup(controller)
.header("principal", "admin")
.header("authorization", "authtoken")
.accept("application/json")
.when()
.post(REST_REQUEST_PATH)
.then()
.statusCode(200)
.statusLine("200");
}
我的控制器就是这样,我需要使用RestDocs生成一个文档:
@PostMapping(value = Constants.LOGOUT_URL)
public String logout (HttpServletRequest request) throws ApiException {
String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
try {
String tokenValue = authHeader.replace("Bearer", "").trim();
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
tokenStore.removeAccessToken(accessToken);
} catch (Exception e) {
return HttpStatus.NOT_FOUND.toString();
}
}
return Utils.convertDateTime();
}