Skip to content

Commit

Permalink
fix: v3httpfilter: Fix the error JSON
Browse files Browse the repository at this point in the history
The important change here is that there was an extra trailing comma that
makes it be invalid JSON.  But also, I intended for it to be
pretty-formatted JSON, but there weren't any newlines.

Signed-off-by: Luke Shumaker <[email protected]>
  • Loading branch information
LukeShu committed Jun 27, 2022
1 parent 9d1a692 commit e403ecd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/ambassador/envoy/v3/v3httpfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def V3HTTPFilter_authv1(auth: IRAuth, v3config: 'V3Config'):
request_handle:respond(
{[":status"] = "500",
["content-type"] = "application/json"},
'{'..
' "message": "the """+auth.rkey+""" AuthService is misconfigured; see the logs for more information",'..
' "request_id": "'..request_handle:headers():get('x-request-id')..'",'..
' "status_code": 500,'..
'}')
'{\\n'..
' "message": "the """+auth.rkey+""" AuthService is misconfigured; see the logs for more information",\\n'..
' "request_id": "'..request_handle:headers():get('x-request-id')..'",\\n'..
' "status_code": 500\\n'..
'}\\n')
end
""",
},
Expand Down
7 changes: 7 additions & 0 deletions python/tests/kat/t_extauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,13 @@ def queries(self):

def check(self):
if self.expected_protocol_version == 'invalid':
for i, result in enumerate(self.results):
# Verify the basic structure of the HTTP 500's JSON body.
assert result.json, f"self.results[{i}] does not have a JSON body"
assert result.json['status_code'] == 500, f"self.results[{i}] JSON body={repr(result.json)} does not have status_code=500"
assert result.json['request_id'], f"self.results[{i}] JSON body={repr(result.json)} does not have request_id"
assert self.path.k8s in result.json['message'], f"self.results[{i}] JSON body={repr(result.json)} does not have thing-containing-the-annotation-containing-the-AuthService name {repr(self.path.k8s)} in message"
assert 'AuthService' in result.json['message'], f"self.results[{i}] JSON body={repr(result.json)} does not have type 'AuthService' in message"
return

# [0] Verifies all request headers sent to the authorization server.
Expand Down

0 comments on commit e403ecd

Please sign in to comment.