Skip to content

Commit 47ab8bc

Browse files
authored
more valid truthy values (#5760)
1 parent 72a48b6 commit 47ab8bc

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tests/appsec/test_asm_standalone.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
UUID_USER = "testuuid"
1717
PASSWORD = "1234"
1818

19+
TRUTHY_VALUES = ["yes", "true", "t", "1"]
20+
1921

2022
# This methods exist to test the 2 different ways of setting the tags in the tracers.
2123
# In some tracers, the propagation tags are set in the first span of every trace chunk,
@@ -157,7 +159,7 @@ def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1
157159

158160
# Some tracers use true while others use yes
159161
assert any(
160-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
162+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
161163
for header, value in data["request"]["headers"]
162164
)
163165
spans_checked += 1
@@ -203,7 +205,7 @@ def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self)
203205

204206
# Some tracers use true while others use yes
205207
assert any(
206-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
208+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
207209
for header, value in data["request"]["headers"]
208210
)
209211
spans_checked += 1
@@ -249,7 +251,7 @@ def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self)
249251

250252
# Some tracers use true while others use yes
251253
assert any(
252-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
254+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
253255
for header, value in data["request"]["headers"]
254256
)
255257
spans_checked += 1
@@ -295,7 +297,7 @@ def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self)
295297

296298
# Some tracers use true while others use yes
297299
assert any(
298-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
300+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
299301
for header, value in data["request"]["headers"]
300302
)
301303
spans_checked += 1
@@ -339,7 +341,7 @@ def test_no_upstream_appsec_propagation__with_asm_event__is_kept_with_priority_2
339341

340342
# Some tracers use true while others use yes
341343
assert any(
342-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
344+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
343345
for header, value in data["request"]["headers"]
344346
)
345347
spans_checked += 1
@@ -383,7 +385,7 @@ def test_no_upstream_appsec_propagation__with_asm_event__is_kept_with_priority_2
383385

384386
# Some tracers use true while others use yes
385387
assert any(
386-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
388+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
387389
for header, value in data["request"]["headers"]
388390
)
389391
spans_checked += 1
@@ -429,7 +431,7 @@ def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_0
429431

430432
# Some tracers use true while others use yes
431433
assert any(
432-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
434+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
433435
for header, value in data["request"]["headers"]
434436
)
435437
spans_checked += 1
@@ -474,7 +476,7 @@ def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1
474476

475477
# Some tracers use true while others use yes
476478
assert any(
477-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
479+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
478480
for header, value in data["request"]["headers"]
479481
)
480482
spans_checked += 1
@@ -519,7 +521,7 @@ def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2
519521

520522
# Some tracers use true while others use yes
521523
assert any(
522-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
524+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
523525
for header, value in data["request"]["headers"]
524526
)
525527
spans_checked += 1
@@ -561,7 +563,7 @@ def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_mi
561563

562564
# Some tracers use true while others use yes
563565
assert any(
564-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
566+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
565567
for header, value in data["request"]["headers"]
566568
)
567569
spans_checked += 1
@@ -603,7 +605,7 @@ def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(
603605

604606
# Some tracers use true while others use yes
605607
assert any(
606-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
608+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
607609
for header, value in data["request"]["headers"]
608610
)
609611
spans_checked += 1
@@ -645,7 +647,7 @@ def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(
645647

646648
# Some tracers use true while others use yes
647649
assert any(
648-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
650+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
649651
for header, value in data["request"]["headers"]
650652
)
651653
spans_checked += 1
@@ -907,7 +909,7 @@ def check_trace_retained(request: HttpResponse, *, should_be_retained: bool) ->
907909
# Check for client-computed-stats header
908910
headers = data["request"]["headers"]
909911
assert any(
910-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
912+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
911913
for header, value in headers
912914
)
913915
spans_checked += 1
@@ -1067,7 +1069,7 @@ def _get_standalone_span_meta(self, trace_id: int):
10671069

10681070
# Some tracers use true while others use yes
10691071
assert any(
1070-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
1072+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
10711073
for header, value in data["request"]["headers"]
10721074
)
10731075
return span["meta"]
@@ -1145,7 +1147,7 @@ def _get_standalone_span_meta(self, trace_id: int):
11451147

11461148
# Some tracers use true while others use yes
11471149
assert any(
1148-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
1150+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
11491151
for header, value in data["request"]["headers"]
11501152
)
11511153
return span["meta"]
@@ -1209,7 +1211,7 @@ def _get_standalone_span_meta(self, trace_id: int):
12091211

12101212
# Some tracers use true while others use yes
12111213
assert any(
1212-
header.lower() == "datadog-client-computed-stats" and value.lower() in ["yes", "true"]
1214+
header.lower() == "datadog-client-computed-stats" and value.lower() in TRUTHY_VALUES
12131215
for header, value in data["request"]["headers"]
12141216
)
12151217
return span["meta"]

0 commit comments

Comments
 (0)