diff --git a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/CommonTests.groovy b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/CommonTests.groovy index 8ce428d5f6d..842f0567e12 100644 --- a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/CommonTests.groovy +++ b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/CommonTests.groovy @@ -271,7 +271,6 @@ trait CommonTests { @Test void 'trace without event'() { def respContentType = null - def respContentLength = null def trace = container.traceFromRequest('/hello.php') { HttpResponse resp -> assert resp.statusCode() == 200 def headerContentType = resp.headers().firstValue('Content-Type') @@ -288,6 +287,28 @@ trait CommonTests { assert span.meta."http.response.headers.content-language" == 'en' } + @Test + void 'response with zero content-length'() { + def trace = container.traceFromRequest('/zero_content_length.php') { HttpResponse resp -> + assert resp.statusCode() == 200 + } + + def spanContentLength = trace.first().meta."http.response.headers.content-length" + assert spanContentLength instanceof String + assert spanContentLength == '0' + } + + @Test + void 'response with non-zero content-length'() { + def trace = container.traceFromRequest('/non_zero_content_length.php') { HttpResponse resp -> + assert resp.statusCode() == 200 + } + + def spanContentLength = trace.first().meta."http.response.headers.content-length" + assert spanContentLength instanceof String + assert spanContentLength == '12' + } + @Test void 'trace with an attack'() { HttpRequest req = container.buildReq('/hello.php') diff --git a/appsec/tests/integration/src/test/www/base/public/non_zero_content_length.php b/appsec/tests/integration/src/test/www/base/public/non_zero_content_length.php new file mode 100644 index 00000000000..373b595cd25 --- /dev/null +++ b/appsec/tests/integration/src/test/www/base/public/non_zero_content_length.php @@ -0,0 +1,5 @@ +