Skip to content

Commit

Permalink
Fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-palii committed Jul 25, 2023
1 parent 1dd8bfa commit acee342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions temba/channels/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ def basic_reduction():
return result

redacted = basic_reduction()
if force_redact_keys and self.msg_id:
redacted = redact.http_trace(redacted, self.msg.contact_urn.path, mask, force_redact_keys)
if force_redact_keys:
redacted = redact.http_trace(redacted, "********", mask, force_redact_keys)

return redacted

Expand Down
6 changes: 4 additions & 2 deletions temba/utils/redact.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def replace_headers(raw_data, headers_to_replace):
try:
headers = OrderedDict()
raw_headers, raw_body = raw_data.split(HTTP_BODY_BOUNDARY)
split_headers = str(raw_headers).split("\r\n")

# parse headers
for line in str(raw_headers).split("\r\n")[1:]:
for line in split_headers[1:]:
key, value = line.split(": ")
headers[key] = value

Expand All @@ -58,7 +59,8 @@ def replace_headers(raw_data, headers_to_replace):
headers[key] = value

# rebuild http message
raw_headers = "\r\n".join([": ".join((key, value)) for key, value in headers.items()])
first_header = split_headers[0].strip()
raw_headers = "\r\n".join([first_header] + [": ".join((key, value)) for key, value in headers.items()])
raw_message = HTTP_BODY_BOUNDARY.join((raw_headers, raw_body))
return raw_message
except (KeyError, ValueError):
Expand Down

0 comments on commit acee342

Please sign in to comment.