Skip to content

Commit

Permalink
tests/test_openpgp: ensure HEAD & Content-Length work in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Robin H. Johnson <[email protected]>
  • Loading branch information
robbat2 committed Apr 21, 2023
1 parent c4cda2e commit c6a2eb8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/test_openpgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,24 +934,25 @@ def test_refresh_wkd(openpgp_env_with_refresh,
# 01 = The server SHOULD return "application/octet-string" as the content-type
content_type_ = 'application/octet-stream'
status_ = 200
headers_ = { 'Content-Length': len(body_) } # needed esp. for HEAD
else:
body_ = None
content_type_ = None
status_ = 404
responses.add(
responses.GET,
'https://example.com/.well-known/openpgpkey/hu/'
'5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato',
body=body_,
content_type=content_type_,
status=status_)
responses.add(
responses.GET,
'https://openpgpkey.example.com/.well-known/openpgpkey/example.org/hu/'
'5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato',
body=body_,
content_type=content_type_,
status=status_)
headers_ = None
url1 = 'https://example.com/.well-known/openpgpkey/hu/' \
'5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato'
url2 = 'https://openpgpkey.example.com/.well-known/openpgpkey/example.org/hu/' \
'5x66h616iaskmnadrm86ndo6xnxbxjxb?l=gemato'
for method_ in [responses.GET, responses.HEAD]:
for url_ in [url1, url2]:
body__ = body_ if method_ == responses.HEAD else None
responses.add(
method_, url_,
body=body__,
content_type=content_type_,
headers=headers_,
status=status_)

if expected is None:
openpgp_env_with_refresh.refresh_keys(
Expand Down

0 comments on commit c6a2eb8

Please sign in to comment.