3131
3232class API10 :
3333 TAGS_EXPECTED : list [tuple [str , str ]] = []
34+ TAGS_EXPECTED_METRIC : list [tuple [str , str ]] = []
3435
3536 def validate (self , span : dict ):
3637 if span .get ("parent_id" ) not in (0 , None ):
@@ -49,7 +50,7 @@ def validate(self, span: dict):
4950 return True
5051
5152 def validate_metric (self , span : dict ):
52- for tag , expected in self .TAGS_EXPECTED :
53+ for tag , expected in self .TAGS_EXPECTED_METRIC :
5354 # check also in meta to be safe
5455 assert tag in span ["metrics" ] or tag in span ["meta" ], f"Missing { tag } from span's meta/metrics"
5556 values = span ["metrics" ] if tag in span ["metrics" ] else span ["meta" ]
@@ -241,7 +242,7 @@ def test_api10(self):
241242class Test_API10_downstream_request_tag (API10 ):
242243 """API 10 span tag validation"""
243244
244- TAGS_EXPECTED = [
245+ TAGS_EXPECTED_METRIC = [
245246 ("_dd.appsec.downstream_request" , "1" ),
246247 ]
247248
@@ -348,3 +349,29 @@ def test_api10_res_body(self):
348349 assert "error" not in body
349350 assert int (body ["status" ]) == 200
350351 interfaces .library .validate_one_span (self .r , validator = self .validate_absence )
352+
353+
354+ @rfc ("https://docs.google.com/document/d/1gCXU3LvTH9en3Bww0AC2coSJWz1m7HcavZjvMLuDCWg/edit#heading=h.giijrtyn1fdx" )
355+ @features .api10
356+ @scenarios .appsec_rasp
357+ @scenarios .appsec_standalone_rasp
358+ class Test_API10_redirect (API10 ):
359+ """API 10 for multiple redirect responses"""
360+
361+ TAGS_EXPECTED = [
362+ ("_dd.appsec.trace.req_headers" , "TAG_API10_REQ_HEADERS" ),
363+ ]
364+
365+ TAGS_EXPECTED_METRIC = [
366+ ("_dd.appsec.downstream_request" , "5" ),
367+ ]
368+
369+ PARAMS = {"Witness" : "pwq3ojtropiw3hjtowir" , "totalRedirects" : "3" }
370+
371+ def setup_api10_redirect (self ):
372+ self .r = weblog .get ("/external_request/redirect" , params = self .PARAMS )
373+
374+ def test_api10_redirect (self ):
375+ assert self .r .status_code == 200
376+ interfaces .library .validate_one_span (self .r , validator = self .validate )
377+ interfaces .library .validate_one_span (self .r , validator = self .validate_metric )
0 commit comments