@@ -91,7 +91,12 @@ public void itShouldCancelEventIfUserAgentIsABotPattern() {
91
91
@ Test
92
92
public void itShouldAddRequestInfoToEvent () {
93
93
HttpRequest httpRequest =
94
- HttpRequest .newBuilder ().uri (URI .create ("http://localhost:5000/test-path" )).GET ().build ();
94
+ HttpRequest .newBuilder ()
95
+ .uri (URI .create ("http://localhost:5000/test-path" ))
96
+ .header ("test-header" , "test-header-value" )
97
+ .header ("test-header" , "test-header-value-2" )
98
+ .GET ()
99
+ .build ();
95
100
context =
96
101
EventPluginContext .builder ()
97
102
.event (Event .builder ().build ())
@@ -108,6 +113,8 @@ public void itShouldAddRequestInfoToEvent() {
108
113
assertThat (requestInfo .getHost ()).isEqualTo ("localhost" );
109
114
assertThat (requestInfo .getPath ()).isEqualTo ("/test-path" );
110
115
assertThat (requestInfo .getPort ()).isEqualTo (5000 );
116
+ assertThat (requestInfo .getHeaders ())
117
+ .isEqualTo (Map .of ("test-header" , List .of ("test-header-value" , "test-header-value-2" )));
111
118
}
112
119
113
120
@ Test
@@ -163,8 +170,7 @@ public void itCanGetIpAddressCookiesAndQueryStringFromAHttpRequest() {
163
170
.context (PluginContext .builder ().request (httpRequest ).build ())
164
171
.build ();
165
172
166
- PrivateInformationInclusions inclusions =
167
- configuration .getPrivateInformationInclusions ();
173
+ PrivateInformationInclusions inclusions = configuration .getPrivateInformationInclusions ();
168
174
inclusions .setIpAddress (true );
169
175
inclusions .setCookies (true );
170
176
inclusions .setQueryString (true );
@@ -187,7 +193,15 @@ public void itCanExcludeData() {
187
193
.uri (
188
194
URI .create (
189
195
"https://localhost:5000/test-path?query-param-key=query-param-value&exclude-query-param=exclude-value" ))
190
- .header ("Cookie" , "cookie1=value1;cookie2=value2;exclude-cookie=exclude-value" )
196
+ .headers (
197
+ "Cookie" ,
198
+ "cookie1=value1;cookie2=value2;exclude-cookie=exclude-value" ,
199
+ "test-header" ,
200
+ "test-value" ,
201
+ "Authorization" ,
202
+ "test-auth" ,
203
+ "exclude-header" ,
204
+ "exclude-value" )
191
205
.GET ()
192
206
.build ();
193
207
@@ -196,9 +210,8 @@ public void itCanExcludeData() {
196
210
.event (Event .builder ().build ())
197
211
.context (PluginContext .builder ().request (httpRequest ).build ())
198
212
.build ();
199
- configuration .addDataExclusions ("exclude-query-param" , "exclude-cookie" );
200
- PrivateInformationInclusions inclusions =
201
- configuration .getPrivateInformationInclusions ();
213
+ configuration .addDataExclusions ("exclude-query-param" , "exclude-cookie" , "exclude-header" );
214
+ PrivateInformationInclusions inclusions = configuration .getPrivateInformationInclusions ();
202
215
inclusions .setIpAddress (true );
203
216
inclusions .setCookies (true );
204
217
inclusions .setQueryString (true );
@@ -212,5 +225,6 @@ public void itCanExcludeData() {
212
225
.isEqualTo (Map .of ("cookie1" , "value1" , "cookie2" , "value2" ));
213
226
assertThat (requestInfo .getQueryString ())
214
227
.isEqualTo (Map .of ("query-param-key" , List .of ("query-param-value" )));
228
+ assertThat (requestInfo .getHeaders ()).isEqualTo (Map .of ("test-header" , List .of ("test-value" )));
215
229
}
216
230
}
0 commit comments