Skip to content

Commit 9abb642

Browse files
committed
Fix: vm client sessions wasn't close + authentifications for test will use localhost as domain
1 parent 301814a commit 9abb642

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tests/unit/aleph_vm_authentication.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
logger = logging.getLogger(__name__)
2020

21+
DOMAIN_NAME = "localhost"
2122

2223
def is_token_still_valid(datestr: str):
2324
"""
@@ -210,9 +211,9 @@ async def authenticate_jwk(request: web.Request) -> str:
210211
"""Authenticate a request using the X-SignedPubKey and X-SignedOperation headers."""
211212
signed_pubkey = get_signed_pubkey(request)
212213
signed_operation = get_signed_operation(request)
213-
if signed_pubkey.content.domain != settings.DOMAIN_NAME:
214+
if signed_pubkey.content.domain != DOMAIN_NAME:
214215
logger.debug(
215-
f"Invalid domain '{signed_pubkey.content.domain}' != '{settings.DOMAIN_NAME}'"
216+
f"Invalid domain '{signed_pubkey.content.domain}' != '{DOMAIN_NAME}'"
216217
)
217218
raise web.HTTPUnauthorized(reason="Invalid domain")
218219
if signed_operation.content.path != request.path:
@@ -232,9 +233,9 @@ async def authenticate_websocket_message(message) -> str:
232233
"""Authenticate a websocket message since JS cannot configure headers on WebSockets."""
233234
signed_pubkey = SignedPubKeyHeader.parse_obj(message["X-SignedPubKey"])
234235
signed_operation = SignedOperation.parse_obj(message["X-SignedOperation"])
235-
if signed_pubkey.content.node_url != settings.DOMAIN_NAME:
236+
if signed_pubkey.content.node_url != DOMAIN_NAME:
236237
logger.debug(
237-
f"Invalid domain '{signed_pubkey.content.node_url}' != '{settings.DOMAIN_NAME}'"
238+
f"Invalid domain '{signed_pubkey.content.node_url}' != '{DOMAIN_NAME}'"
238239
)
239240
raise web.HTTPUnauthorized(reason="Invalid domain")
240241
return verify_signed_operation(signed_operation, signed_pubkey)

tests/unit/test_vmclient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ async def test_notify_allocation():
2121
m.post("http://localhost/control/allocation/notify", status=200)
2222
await vm_client.notify_allocation(vm_id=vm_id)
2323
assert m.requests
24+
await vm_client.session.close()

0 commit comments

Comments
 (0)