我有一个休息请求的响应日志,如下所示:
Request method: DELETE
Request URI: https://Some_URI
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Authorization=Bearer AuthenticationTocken
Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body: <none>
我想记录整个响应,但不记录标题中的授权部分,结果应如此。
Request method: DELETE
Request URI: https://Some_URI
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body: <none>
使用代码创建标题:
Map<String, Object> headers = new HashMap<>();
headers.put( HttpHeaders.CONTENT_TYPE,ContentType.JSON);
headers.put( HttpHeaders.ACCEPT,ContentType.ANY);
RequestSpecification requestSpecification = given().log().all()
.header(HttpHeaders.AUTHORIZATION, BEARER_KEY + getAuthorizationToken())
.headers(headers);
我相信您正在使用“确保放心”进行测试,在这种情况下,您无法完全删除标题,但可以隐藏详细信息-blacklist-headers-from-logging