Skip to content

Commit

Permalink
Add test to check absence of client computed stats
Browse files Browse the repository at this point in the history
  • Loading branch information
estringana committed Jan 15, 2025
1 parent 6c556b6 commit 3c1c3b2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ tests/:
test_telemetry.py:
Test_TelemetryMetrics: missing_feature
test_asm_standalone.py:
Test_AppSecStandalone_NotEnabled: v1.6.2
Test_AppSecStandalone_UpstreamPropagation: v1.6.0
Test_IastStandalone_UpstreamPropagation: missing_feature
Test_SCAStandalone_Telemetry: missing_feature
Expand Down
33 changes: 33 additions & 0 deletions tests/appsec/test_asm_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,39 @@ def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(
assert downstream_headers["X-Datadog-Trace-Id"] == "1212121212121212121"


@rfc("https://docs.google.com/document/d/12NBx-nD-IoQEMiCRnJXneq4Be7cbtSc6pJLOFUWTpNE/edit")
@features.appsec_standalone_not_enabled
@scenarios.appsec_standalone_not_enabled
class Test_AppSecStandalone_NotEnabled:
"""Test expected behaviour when standalone is not enabled."""

def setup_client_computed_stats_header_is_not_present(self):
trace_id = 1212121212121212122
parent_id = 34343435
self.r = weblog.get(
"/requestdownstream",
headers={
"x-datadog-trace-id": str(trace_id),
"x-datadog-parent-id": str(parent_id),
"x-datadog-sampling-priority": "-1",
"x-datadog-origin": "rum",
"x-datadog-tags": "_dd.p.other=1",
},
)

def test_client_computed_stats_header_is_not_present(self):
spans_checked = 0
for data, trace, span in interfaces.library.get_spans(request=self.r):
# Some tracers use true while others use yes
assert span["trace_id"] == 1212121212121212122
assert "Datadog-Client-Computed-Stats" not in [x for x, y in data["request"]["headers"]]
spans_checked += 1

assert spans_checked == 1
downstream_headers = CaseInsensitiveDict(json.loads(self.r.text))
assert "Datadog-Client-Computed-Stats" not in downstream_headers


@rfc("https://docs.google.com/document/d/12NBx-nD-IoQEMiCRnJXneq4Be7cbtSc6pJLOFUWTpNE/edit")
@features.appsec_standalone
@scenarios.appsec_standalone
Expand Down
9 changes: 9 additions & 0 deletions utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ class _Scenarios:
scenario_groups=[ScenarioGroup.APPSEC],
)

appsec_standalone_not_enabled = EndToEndScenario(
"APPSEC_STANDALONE_NOT_ENABLED",
weblog_env={
"DD_APPSEC_ENABLED": "true",
},
doc="Appsec standalone not enabled",
scenario_groups=[ScenarioGroup.APPSEC],
)

appsec_standalone = EndToEndScenario(
"APPSEC_STANDALONE",
weblog_env={
Expand Down
9 changes: 9 additions & 0 deletions utils/_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,15 @@ def appsec_standalone(test_object):
pytest.mark.features(feature_id=305)(test_object)
return test_object

@staticmethod
def appsec_standalone_not_enabled(test_object):
"""Appsec Standalone Billing not enabled
https://feature-parity.us1.prod.dog/#/?feature=306
"""
pytest.mark.features(feature_id=306)(test_object)
return test_object

@staticmethod
def iast_standalone(test_object):
"""Iast Standalone Billing
Expand Down

0 comments on commit 3c1c3b2

Please sign in to comment.