Skip to content

Commit

Permalink
fix: clear X-Amzn-Trace-Id in httbin.org responses
Browse files Browse the repository at this point in the history
The httbin.org service returns a X-Amzn-Trace-Id header in its
responses, which is different for each request. This causes the
tests to fail. This clears the header before comparing responses.

Refs: #184, #190
Signed-off-by: Jaremy Hatler <hatler.jaremy@gmail.com>
  • Loading branch information
jhatler committed Dec 23, 2023
1 parent 8aa9f34 commit b697764
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/integration/test_record_modes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from betamax import Betamax, BetamaxError

from tests.integration.helper import IntegrationHelper
Expand Down Expand Up @@ -39,8 +41,15 @@ def test_replays_response_from_cassette(self):
# this test to succeed.
# NOTE(hroncok): httpbin.org added X-Processed-Time header that
# can possibly differ (and often does)
r0_content = r0.content.decode(encoding='utf-8', errors='strict')
r1_content = r1.content.decode(encoding='utf-8', errors='strict')
r0_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r0_content)
r1_content = re.sub('"X-Amzn-Trace-Id": "[^"]+"', '"X-Amzn-Trace-Id": ""', r1_content)
# NOTE(jhatler): httpbin.org added "X-Amzn-Trace-Id" to their
# response, which is a unique ID that will differ between requests.
# We remove it from the response body before comparing.
assert r0_headers == r1_headers
assert r0.content == r1.content
assert r0_content == r1_content


class TestRecordNone(IntegrationHelper):
Expand Down

0 comments on commit b697764

Please sign in to comment.