@@ -91,7 +91,12 @@ public void itShouldCancelEventIfUserAgentIsABotPattern() {
9191 @ Test
9292 public void itShouldAddRequestInfoToEvent () {
9393 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 ();
95100 context =
96101 EventPluginContext .builder ()
97102 .event (Event .builder ().build ())
@@ -108,6 +113,8 @@ public void itShouldAddRequestInfoToEvent() {
108113 assertThat (requestInfo .getHost ()).isEqualTo ("localhost" );
109114 assertThat (requestInfo .getPath ()).isEqualTo ("/test-path" );
110115 assertThat (requestInfo .getPort ()).isEqualTo (5000 );
116+ assertThat (requestInfo .getHeaders ())
117+ .isEqualTo (Map .of ("test-header" , List .of ("test-header-value" , "test-header-value-2" )));
111118 }
112119
113120 @ Test
@@ -163,8 +170,7 @@ public void itCanGetIpAddressCookiesAndQueryStringFromAHttpRequest() {
163170 .context (PluginContext .builder ().request (httpRequest ).build ())
164171 .build ();
165172
166- PrivateInformationInclusions inclusions =
167- configuration .getPrivateInformationInclusions ();
173+ PrivateInformationInclusions inclusions = configuration .getPrivateInformationInclusions ();
168174 inclusions .setIpAddress (true );
169175 inclusions .setCookies (true );
170176 inclusions .setQueryString (true );
@@ -187,7 +193,15 @@ public void itCanExcludeData() {
187193 .uri (
188194 URI .create (
189195 "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" )
191205 .GET ()
192206 .build ();
193207
@@ -196,9 +210,8 @@ public void itCanExcludeData() {
196210 .event (Event .builder ().build ())
197211 .context (PluginContext .builder ().request (httpRequest ).build ())
198212 .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 ();
202215 inclusions .setIpAddress (true );
203216 inclusions .setCookies (true );
204217 inclusions .setQueryString (true );
@@ -212,5 +225,6 @@ public void itCanExcludeData() {
212225 .isEqualTo (Map .of ("cookie1" , "value1" , "cookie2" , "value2" ));
213226 assertThat (requestInfo .getQueryString ())
214227 .isEqualTo (Map .of ("query-param-key" , List .of ("query-param-value" )));
228+ assertThat (requestInfo .getHeaders ()).isEqualTo (Map .of ("test-header" , List .of ("test-value" )));
215229 }
216230}
0 commit comments