Skip to content

Commit 1e4e714

Browse files
committed
Fix tests
1 parent 3c6eb4c commit 1e4e714

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/TelemetryTests.groovy

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.junit.jupiter.api.Order
1414
import org.junit.jupiter.api.Test
1515
import org.junit.jupiter.api.TestMethodOrder
1616
import org.junit.jupiter.api.condition.DisabledIf
17+
import org.testcontainers.containers.BindMode
1718
import org.testcontainers.junit.jupiter.Container
1819
import org.testcontainers.junit.jupiter.Testcontainers
1920

@@ -49,6 +50,12 @@ class TelemetryTests {
4950
void configure() {
5051
super.configure()
5152
withEnv('RUST_LIB_BACKTRACE', '1')
53+
// This class strips appsec.rules from php.ini (see beforeAll) to exercise
54+
// the helpers' default-ruleset path, so both helpers must see the real
55+
// production ruleset here instead of the test fixture at
56+
// src/test/waf/recommended.json.
57+
setBinds(binds.findAll { it.volume.path != '/etc/recommended.json' })
58+
withFileSystemBind('../../recommended.json', '/etc/recommended.json', BindMode.READ_ONLY)
5259
}
5360
}
5461

@@ -935,10 +942,11 @@ class TelemetryTests {
935942
}
936943
assert requestSup.get() != null
937944

938-
// Blocking request: 80.80.80.80 hits the recommended.json IP blocklist rule
939-
// (on_match: ["block"]). The WAF returns a block_request action.
945+
// Blocking request: this User-Agent hits the recommended.json Datadog test
946+
// scanner rule (ua0-600-56x, on_match: ["block"]). The WAF returns a
947+
// block_request action.
940948
HttpRequest req = CONTAINER.buildReq('/hello.php')
941-
.header('X-Forwarded-For', '80.80.80.80').GET().build()
949+
.header('User-Agent', 'dd-test-scanner-log-block').GET().build()
942950
CONTAINER.traceFromRequest(req, ofString()) { HttpResponse<String> resp ->
943951
assert resp.statusCode() == 403
944952
}
@@ -1163,7 +1171,7 @@ class TelemetryTests {
11631171
],
11641172
'datadog/2/ASM/rasp_lfi_block_override/config': [
11651173
rules_override: [[
1166-
rules_target: [[rule_id: 'rasp-001-001']],
1174+
rules_target: [[rule_id: 'rasp-930-100']],
11671175
on_match: ['block']
11681176
]]
11691177
]

0 commit comments

Comments
 (0)