Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e358144b
Commit
e358144b
authored
Aug 11, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Exclude cookie headers by default from HTTP traces"
See gh-22829
parent
5ff51572
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
HttpTraceProperties.java
...actuate/autoconfigure/trace/http/HttpTraceProperties.java
+2
-3
HttpExchangeTracerTests.java
...work/boot/actuate/trace/http/HttpExchangeTracerTests.java
+24
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceProperties.java
View file @
e358144b
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -37,8 +37,7 @@ public class HttpTraceProperties {
...
@@ -37,8 +37,7 @@ public class HttpTraceProperties {
/**
/**
* Items to be included in the trace. Defaults to request headers (excluding
* Items to be included in the trace. Defaults to request headers (excluding
* Authorization but including Cookie), response headers (including Set-Cookie), and
* Authorization and Cookie), response headers (excluding Set-Cookie), and time taken.
* time taken.
*/
*/
private
Set
<
Include
>
include
=
new
HashSet
<>(
Include
.
defaultIncludes
());
private
Set
<
Include
>
include
=
new
HashSet
<>(
Include
.
defaultIncludes
());
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracerTests.java
View file @
e358144b
...
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
...
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
import
org.springframework.boot.actuate.trace.http.HttpTrace.Request
;
import
org.springframework.boot.actuate.trace.http.HttpTrace.Request
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
...
@@ -270,6 +271,29 @@ class HttpExchangeTracerTests {
...
@@ -270,6 +271,29 @@ class HttpExchangeTracerTests {
assertThat
(
trace
.
getTimeTaken
()).
isNotNull
();
assertThat
(
trace
.
getTimeTaken
()).
isNotNull
();
}
}
@Test
void
defaultIncludes
()
{
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setAccept
(
Arrays
.
asList
(
MediaType
.
APPLICATION_JSON
));
requestHeaders
.
set
(
HttpHeaders
.
COOKIE
,
"value"
);
requestHeaders
.
set
(
HttpHeaders
.
AUTHORIZATION
,
"secret"
);
HttpExchangeTracer
tracer
=
new
HttpExchangeTracer
(
Include
.
defaultIncludes
());
HttpTrace
trace
=
tracer
.
receivedRequest
(
createRequest
(
requestHeaders
));
HttpHeaders
responseHeaders
=
new
HttpHeaders
();
responseHeaders
.
set
(
HttpHeaders
.
SET_COOKIE
,
"test=test"
);
responseHeaders
.
setContentLength
(
0
);
tracer
.
sendingResponse
(
trace
,
createResponse
(
responseHeaders
),
this
::
createPrincipal
,
()
->
"sessionId"
);
assertThat
(
trace
.
getTimeTaken
()).
isNotNull
();
assertThat
(
trace
.
getPrincipal
()).
isNull
();
assertThat
(
trace
.
getSession
()).
isNull
();
assertThat
(
trace
.
getTimestamp
()).
isNotNull
();
assertThat
(
trace
.
getRequest
().
getMethod
()).
isEqualTo
(
"GET"
);
assertThat
(
trace
.
getRequest
().
getRemoteAddress
()).
isNull
();
assertThat
(
trace
.
getResponse
().
getStatus
()).
isEqualTo
(
204
);
assertThat
(
trace
.
getRequest
().
getHeaders
()).
containsOnlyKeys
(
HttpHeaders
.
ACCEPT
);
assertThat
(
trace
.
getResponse
().
getHeaders
()).
containsOnlyKeys
(
HttpHeaders
.
CONTENT_LENGTH
);
}
private
TraceableRequest
createRequest
()
{
private
TraceableRequest
createRequest
()
{
return
createRequest
(
Collections
.
singletonMap
(
HttpHeaders
.
ACCEPT
,
Arrays
.
asList
(
"application/json"
)));
return
createRequest
(
Collections
.
singletonMap
(
HttpHeaders
.
ACCEPT
,
Arrays
.
asList
(
"application/json"
)));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment