11package datadog.trace.agent.test.base
22
3- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_JSON
4- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_MULTIPART
5- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_URLENCODED
6- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CREATED
7- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CREATED_IS
8- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CUSTOM_EXCEPTION
9- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.ERROR
10- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
11- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.FORWARDED
12- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
13- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
14- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_ENCODED_BOTH
15- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_ENCODED_QUERY
16- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
17- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.REDIRECT
18- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SESSION_ID
19- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SUCCESS
20- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.TIMEOUT
21- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.TIMEOUT_ERROR
22- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.UNKNOWN
23- import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.USER_BLOCK
24- import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
25- import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
26- import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_RAW_QUERY_STRING
27- import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_RAW_RESOURCE
28- import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_TAG_QUERY_STRING
29- import static datadog.trace.api.config.TraceInstrumentationConfig.SERVLET_ASYNC_TIMEOUT_ERROR
30- import static datadog.trace.api.config.TracerConfig.HEADER_TAGS
31- import static datadog.trace.api.config.TracerConfig.REQUEST_HEADER_TAGS
32- import static datadog.trace.api.config.TracerConfig.RESPONSE_HEADER_TAGS
33- import static datadog.trace.bootstrap.blocking.BlockingActionHelper.TemplateType.JSON
34- import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope
35- import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan
36- import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.get
37- import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan
38- import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.SERVER_PATHWAY_EDGE_TAGS
39- import static java.nio.charset.StandardCharsets.UTF_8
40- import static org.junit.Assume.assumeTrue
41-
423import ch.qos.logback.classic.Level
434import datadog.appsec.api.blocking.Blocking
445import datadog.appsec.api.blocking.BlockingContentType
@@ -90,6 +51,45 @@ import java.util.function.BiFunction
9051import java.util.function.Function
9152import java.util.function.Supplier
9253
54+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_JSON
55+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_MULTIPART
56+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.BODY_URLENCODED
57+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CREATED
58+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CREATED_IS
59+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.CUSTOM_EXCEPTION
60+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.ERROR
61+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
62+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.FORWARDED
63+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
64+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
65+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_ENCODED_BOTH
66+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_ENCODED_QUERY
67+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
68+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.REDIRECT
69+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SESSION_ID
70+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.SUCCESS
71+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.TIMEOUT
72+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.TIMEOUT_ERROR
73+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.UNKNOWN
74+ import static datadog.trace.agent.test.base.HttpServerTest.ServerEndpoint.USER_BLOCK
75+ import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
76+ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
77+ import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_RAW_QUERY_STRING
78+ import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_RAW_RESOURCE
79+ import static datadog.trace.api.config.TraceInstrumentationConfig.HTTP_SERVER_TAG_QUERY_STRING
80+ import static datadog.trace.api.config.TraceInstrumentationConfig.SERVLET_ASYNC_TIMEOUT_ERROR
81+ import static datadog.trace.api.config.TracerConfig.HEADER_TAGS
82+ import static datadog.trace.api.config.TracerConfig.REQUEST_HEADER_TAGS
83+ import static datadog.trace.api.config.TracerConfig.RESPONSE_HEADER_TAGS
84+ import static datadog.trace.bootstrap.blocking.BlockingActionHelper.TemplateType.JSON
85+ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope
86+ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan
87+ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.get
88+ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan
89+ import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.SERVER_PATHWAY_EDGE_TAGS
90+ import static java.nio.charset.StandardCharsets.UTF_8
91+ import static org.junit.Assume.assumeTrue
92+
9393abstract class HttpServerTest <SERVER> extends WithHttpServer<SERVER> {
9494
9595 public static final Logger SERVER_LOGGER = LoggerFactory . getLogger(" http-server" )
@@ -209,9 +209,9 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
209209 // Only used if hasExtraErrorInformation is true
210210 Map<String , Serializable > expectedExtraErrorInformation (ServerEndpoint endpoint ) {
211211 if (endpoint. errored) {
212- [" error.message" : { it == null || it == EXCEPTION . body },
213- " error.type" : { it == null || it == Exception . name },
214- " error.stack" : { it == null || it instanceof String }]
212+ [" error.message" : { it == null || it == EXCEPTION . body },
213+ " error.type" : { it == null || it == Exception . name },
214+ " error.stack" : { it == null || it instanceof String }]
215215 } else {
216216 Collections . emptyMap()
217217 }
@@ -493,8 +493,8 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
493493 }
494494
495495 private static final Map<String , ServerEndpoint > PATH_MAP = {
496- Map<String , ServerEndpoint > map = values(). collectEntries { [it. path, it] }
497- map. putAll(values(). collectEntries { [it. rawPath, it] })
496+ Map<String , ServerEndpoint > map = values(). collectEntries { [it. path, it]}
497+ map. putAll(values(). collectEntries { [it. rawPath, it]})
498498 map
499499 }. call()
500500
@@ -702,9 +702,9 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
702702 }
703703
704704 where :
705- method | body | header | value | tags
706- ' GET' | null | ' x-datadog-test-both-header' | ' foo' | [' both_header_tag' : ' foo' ]
707- ' GET' | null | ' x-datadog-test-request-header' | ' bar' | [' request_header_tag' : ' bar' ]
705+ method | body | header | value | tags
706+ ' GET' | null | ' x-datadog-test-both-header' | ' foo' | [ ' both_header_tag' : ' foo' ]
707+ ' GET' | null | ' x-datadog-test-request-header' | ' bar' | [ ' request_header_tag' : ' bar' ]
708708 }
709709
710710 @Flaky (value = " https://github.com/DataDog/dd-trace-java/issues/4690" , suites = [" MuleHttpServerForkedTest" ])
@@ -716,7 +716,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
716716 def body = null
717717 def header = IG_RESPONSE_HEADER
718718 def mapping = ' mapped_response_header_tag'
719- def tags = [' mapped_response_header_tag' : " $IG_RESPONSE_HEADER_VALUE " ]
719+ def tags = [' mapped_response_header_tag' : " $IG_RESPONSE_HEADER_VALUE " ]
720720
721721 injectSysConfig(HTTP_SERVER_TAG_QUERY_STRING , " true" )
722722 injectSysConfig(RESPONSE_HEADER_TAGS , " $header :$mapping " )
@@ -799,13 +799,13 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
799799 }
800800
801801 where :
802- rawQuery | endpoint | encoded
803- true | SUCCESS | false
804- true | QUERY_PARAM | false
805- true | QUERY_ENCODED_QUERY | true
806- false | SUCCESS | false
807- false | QUERY_PARAM | false
808- false | QUERY_ENCODED_QUERY | true
802+ rawQuery | endpoint | encoded
803+ true | SUCCESS | false
804+ true | QUERY_PARAM | false
805+ true | QUERY_ENCODED_QUERY | true
806+ false | SUCCESS | false
807+ false | QUERY_PARAM | false
808+ false | QUERY_ENCODED_QUERY | true
809809
810810 method = " GET"
811811 body = null
@@ -918,7 +918,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
918918 }
919919
920920 then :
921- DDSpan span = TEST_WRITER . flatten(). find { it. operationName == ' appsec-span' }
921+ DDSpan span = TEST_WRITER . flatten(). find {it. operationName == ' appsec-span' }
922922 span. getTag(IG_PATH_PARAMS_TAG ) == expectedIGPathParams()
923923
924924 and :
@@ -1612,7 +1612,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
16121612 then :
16131613 TEST_WRITER . waitForTraces(1 )
16141614 def trace = TEST_WRITER . get(0 )
1615- assert trace. find { it. isError() } == null
1615+ assert trace. find {it. isError() } == null
16161616 }
16171617
16181618 def ' test blocking of request for path parameters' () {
@@ -1693,8 +1693,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
16931693 spans. find { it. tags[' appsec.blocked' ] == ' true' } != null
16941694 spans. find {
16951695 it. error &&
1696- it. tags[' error.type' ] == BlockingException . name
1697- } != null
1696+ it. tags[' error.type' ] == BlockingException . name } != null
16981697
16991698 and :
17001699 if (isDataStreamsEnabled()) {
@@ -1874,7 +1873,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
18741873 if (isDataStreamsEnabled()) {
18751874 TEST_DATA_STREAMS_WRITER . waitForGroups(1 )
18761875 }
1877- DDSpan span = TEST_WRITER . flatten(). find { it. operationName == ' appsec-span' }
1876+ DDSpan span = TEST_WRITER . flatten(). find {it. operationName == ' appsec-span' }
18781877 span != null
18791878 final sessionId = span. tags[IG_SESSION_ID_TAG ]
18801879 sessionId != null
0 commit comments