Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
basvandriel committed Dec 4, 2024
1 parent 4af7331 commit f986e45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_nonce(self):
as with all updates, as every request answers with a new nonce.
"""
response = requests.get(
self._directory_configuration.new_nonce_url.geturl(),
self._directory_configuration.new_nonce_url,
timeout=60,
)
self.nonce = response.headers["Replay-Nonce"]
Expand All @@ -74,7 +74,7 @@ def account_request(self, request):
protected = {
"alg": "ES256",
"nonce": self.nonce,
"url": self._directory_configuration.new_account_url.geturl(),
"url": self._directory_configuration.new_account_url,
"jwk": self.key.export_public(True),
}
token = jwt.JWS(payload=json.dumps(request))
Expand All @@ -83,7 +83,7 @@ def account_request(self, request):
headers = {"Content-Type": "application/jose+json"}

response = requests.post(
self._directory_configuration.new_account_url.geturl(),
self._directory_configuration.new_account_url,
data=token.serialize(),
headers=headers,
timeout=60,
Expand All @@ -103,7 +103,7 @@ def create_order(self, keynum, order):
"""
print("Order")

new_order_url = self._directory_configuration.new_order_url.geturl()
new_order_url = self._directory_configuration.new_order_url

protected = {
"alg": "ES256",
Expand Down
9 changes: 4 additions & 5 deletions app/acme_directory_configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass
from urllib.parse import ParseResult as URLParseResult


@dataclass
Expand All @@ -8,7 +7,7 @@ class ACMEDirectoryConfiguration:
This data is generated from the directory endpoint. These endpoints can be different per server.
"""

new_order_url: URLParseResult
new_account_url: URLParseResult
new_nonce_url: URLParseResult
revoke_cert_url: URLParseResult
new_order_url: str
new_account_url: str
new_nonce_url: str
revoke_cert_url: str
8 changes: 4 additions & 4 deletions app/acme_directory_configuration_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

class ACMEDirectoryConfigurationParser:
def _build_conf_from_json(self, json: dict[str, Any]) -> ACMEDirectoryConfiguration:
new_nonce_url = urlparse(
new_nonce_url = str(
json["newNonce"],
)
new_account_url = urlparse(
new_account_url = str(
json["newAccount"],
)
new_order_url = urlparse(
new_order_url = str(
json["newOrder"],
)
revoke_cert_url = urlparse(
revoke_cert_url = str(
json["revokeCert"],
)
conf = ACMEDirectoryConfiguration(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_acme_url_configuration_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
)
def test_url_parse(request_get_mock: MagicMock):
base_url = urlparse("http://localhost:9090/")
expected_request_url = urljoin(base_url.geturl(), "acme/directory")
expected_request_url = urljoin(base_url.geturl(), "/directory")

result: ACMEDirectoryConfiguration = ACMEDirectoryConfigurationParser().parse(
base_url
)

assert result.new_nonce_url.geturl() == "123"
assert result.new_nonce_url == "123"
request_get_mock.assert_called_with(expected_request_url)

0 comments on commit f986e45

Please sign in to comment.