Merge branch '1.5.x'
This commit is contained in:
commit
971057705d
|
|
@ -138,7 +138,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||||
add(trace, Include.USER_PRINCIPAL, "userPrincipal",
|
add(trace, Include.USER_PRINCIPAL, "userPrincipal",
|
||||||
(userPrincipal == null ? null : userPrincipal.getName()));
|
(userPrincipal == null ? null : userPrincipal.getName()));
|
||||||
if (isIncluded(Include.PARAMETERS)) {
|
if (isIncluded(Include.PARAMETERS)) {
|
||||||
trace.put("parameters", request.getParameterMap());
|
trace.put("parameters", getParameterMap(request));
|
||||||
}
|
}
|
||||||
add(trace, Include.QUERY_STRING, "query", request.getQueryString());
|
add(trace, Include.QUERY_STRING, "query", request.getQueryString());
|
||||||
add(trace, Include.AUTH_TYPE, "authType", request.getAuthType());
|
add(trace, Include.AUTH_TYPE, "authType", request.getAuthType());
|
||||||
|
|
@ -190,6 +190,12 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String[]> getParameterMap(HttpServletRequest request) {
|
||||||
|
Map<String, String[]> map = new LinkedHashMap<String, String[]>();
|
||||||
|
map.putAll(request.getParameterMap());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post process request headers before they are added to the trace.
|
* Post process request headers before they are added to the trace.
|
||||||
* @param headers a mutable map containing the request headers to trace
|
* @param headers a mutable map containing the request headers to trace
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,22 @@ public class SampleActuatorApplicationTests {
|
||||||
assertThat(map.get("status")).isEqualTo("200");
|
assertThat(map.get("status")).isEqualTo("200");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void traceWithParameterMap() throws Exception {
|
||||||
|
this.restTemplate.getForEntity("/health?param1=value1", String.class);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ResponseEntity<List> entity = this.restTemplate
|
||||||
|
.withBasicAuth("user", getPassword()).getForEntity("/trace", List.class);
|
||||||
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Map<String, Object>> list = entity.getBody();
|
||||||
|
Map<String, Object> trace = list.get(0);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> map = (Map<String, Object>) ((Map<String, Object>)trace
|
||||||
|
.get("info")).get("parameters");
|
||||||
|
assertThat(map.get("param1")).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testErrorPageDirectAccess() throws Exception {
|
public void testErrorPageDirectAccess() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue