Skip to content

Commit 7c452d3

Browse files
committed
APM-4118 Test for headers being logged as object
1 parent 092ee12 commit 7c452d3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

tests/test_splunk_logging.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ def test_splunk_deny_list_headers_not_logged(
383383
content = payload[message_type]
384384
assert content["headers"]
385385

386-
headers = json.loads(content["headers"])
387-
388386
deny_list = [
389387
"Accept-Coding",
390388
"Accept-Language",
@@ -394,7 +392,7 @@ def test_splunk_deny_list_headers_not_logged(
394392
"Strict-Transport-Security",
395393
]
396394
for denied_header in deny_list:
397-
assert denied_header not in headers
395+
assert denied_header not in content["headers"]
398396

399397
@pytest.mark.nhsd_apim_authorization(
400398
access="application", level="level3", force_new_token=True
@@ -464,10 +462,8 @@ def test_splunk_headers_already_logged_not_duplicated(
464462
content = payload[message_type]
465463
assert content["headers"]
466464

467-
headers = json.loads(content["headers"])
468-
469465
for logged_header in headers_already_logged:
470-
assert logged_header["header_name"] not in headers
466+
assert logged_header["header_name"] not in content["headers"]
471467
assert content[logged_header["splunk_key"]] is not None
472468

473469
@pytest.mark.nhsd_apim_authorization(
@@ -503,7 +499,7 @@ def test_splunk_request_headers_not_overwritten_in_proxy(
503499
content = splunk_payload["request"]
504500
assert content["headers"]
505501

506-
headers = json.loads(content["headers"])
502+
headers = content["headers"]
507503

508504
assert headers["Test-Header-One"] == "foo bar bar foo"
509505
assert headers["Test-Header-Two"] == "bar foo foo bar"

tests/utils/splunk_logging_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"type": "object",
4545
"properties": {
4646
"headers": {
47-
"type": "string"
47+
"type": "object"
4848
},
4949
"uri": {
5050
"type": "string"
@@ -340,7 +340,7 @@
340340
"type": "object",
341341
"properties": {
342342
"headers": {
343-
"type": "string"
343+
"type": "object"
344344
},
345345
"status_code": {
346346
"type": "string",

0 commit comments

Comments
 (0)