Skip to content

Commit 227c0aa

Browse files
Add gateway bridge related tests
1 parent 64e8458 commit 227c0aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/gateway/GatewayBridgeSpecification.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class GatewayBridgeSpecification extends DDSpecification {
9999
BiFunction<RequestContext, StoredBodySupplier, Void> requestBodyStartCB
100100
BiFunction<RequestContext, StoredBodySupplier, Flow<Void>> requestBodyDoneCB
101101
BiFunction<RequestContext, Object, Flow<Void>> requestBodyProcessedCB
102+
BiFunction<RequestContext, Object, Flow<Void>> responseBodyCB
102103
BiFunction<RequestContext, Integer, Flow<Void>> responseStartedCB
103104
TriConsumer<RequestContext, String, String> respHeaderCB
104105
Function<RequestContext, Flow<Void>> respHeadersDoneCB
@@ -449,6 +450,7 @@ class GatewayBridgeSpecification extends DDSpecification {
449450
1 * ig.registerCallback(EVENTS.requestBodyStart(), _) >> { requestBodyStartCB = it[1]; null }
450451
1 * ig.registerCallback(EVENTS.requestBodyDone(), _) >> { requestBodyDoneCB = it[1]; null }
451452
1 * ig.registerCallback(EVENTS.requestBodyProcessed(), _) >> { requestBodyProcessedCB = it[1]; null }
453+
1 * ig.registerCallback(EVENTS.responseBody(), _) >> { responseBodyCB = it[1]; null }
452454
1 * ig.registerCallback(EVENTS.responseStarted(), _) >> { responseStartedCB = it[1]; null }
453455
1 * ig.registerCallback(EVENTS.responseHeader(), _) >> { respHeaderCB = it[1]; null }
454456
1 * ig.registerCallback(EVENTS.responseHeaderDone(), _) >> { respHeadersDoneCB = it[1]; null }
@@ -1314,4 +1316,17 @@ class GatewayBridgeSpecification extends DDSpecification {
13141316
0 * traceSegment.setTagTop(_, _)
13151317
}
13161318
1319+
void 'test on response body callback'() {
1320+
when:
1321+
responseBodyCB.apply(ctx, [test: 'this is a test'])
1322+
1323+
then:
1324+
1 * eventDispatcher.getDataSubscribers(KnownAddresses.RESPONSE_BODY_OBJECT) >> nonEmptyDsInfo
1325+
1 * eventDispatcher.publishDataEvent(_, _, _, _) >> {
1326+
final bundle = it[2] as DataBundle
1327+
final body = bundle.get(KnownAddresses.RESPONSE_BODY_OBJECT)
1328+
assert body['test'] == 'this is a test'
1329+
}
1330+
}
1331+
13171332
}

0 commit comments

Comments
 (0)