-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathHttpRouteHandlerTest.groovy
More file actions
39 lines (32 loc) · 964 Bytes
/
HttpRouteHandlerTest.groovy
File metadata and controls
39 lines (32 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.datadog.iast
import datadog.trace.api.gateway.RequestContext
import datadog.trace.api.gateway.RequestContextSlot
import datadog.trace.test.util.DDSpecification
import groovy.transform.CompileDynamic
@CompileDynamic
class HttpRouteHandlerTest extends DDSpecification {
void 'route is set'() {
given:
final handler = new HttpRouteHandler()
final iastCtx = Mock(IastRequestContext)
final ctx = Mock(RequestContext)
ctx.getData(RequestContextSlot.IAST) >> iastCtx
when:
handler.accept(ctx, '/foo')
then:
1 * ctx.getData(RequestContextSlot.IAST) >> iastCtx
1 * iastCtx.setRoute('/foo')
0 * _
}
void 'does nothing when context missing'() {
given:
final handler = new HttpRouteHandler()
final ctx = Mock(RequestContext)
ctx.getData(RequestContextSlot.IAST) >> null
when:
handler.accept(ctx, '/foo')
then:
1 * ctx.getData(RequestContextSlot.IAST) >> null
0 * _
}
}