Skip to content

Commit cc178b0

Browse files
committed
fix: Apparently we always get the full url as the callsign so filter the deployment out.
1 parent d460088 commit cc178b0

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/rasenmaeher_api/web/api/enduserpfx/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ async def get_user_pfx(
2525
:param callsign: OTTER1.pfx
2626
:returns pfx or 403 error
2727
"""
28+
deplosuffix = f"_{RMSettings.singleton().deployment_name}.pfx"
29+
if callsign.endswith(deplosuffix):
30+
callsign = callsign[: -len(deplosuffix)]
2831
if callsign.endswith(".pfx"):
2932
callsign = callsign[:-4]
3033
LOGGER.debug("Called with callsign={}".format(callsign))

src/rasenmaeher_api/web/api/instructions/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ async def get_product_instructions(request: Request, product: str, language: str
6868
user = UserCRUDRequest(
6969
uuid=str(person.pk), callsign=person.callsign, x509cert=person.certfile.read_text(encoding="utf-8")
7070
)
71-
response = await post_to_product(product, f"api/v1/instructions/{language}", user.dict(), InstructionData)
71+
endpoint_url = f"api/v1/instructions/{language}"
72+
response = await post_to_product(product, endpoint_url, user.dict(), InstructionData)
7273
if response is None:
74+
LOGGER.error("post_to_product({}, {}): failed".format(product, endpoint_url))
7375
# TODO: Raise a reasonable error instead
7476
return None
7577
response = cast(InstructionData, response)

tests/ptfpapi/fprun.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ async def handle_fragment(request: web.Request) -> web.Response:
6363
"""Respond with hello_world for user"""
6464
check_peer_cert(request)
6565
user = UserCRUDRequest.parse_raw(await request.text())
66+
LOGGER.info("Called with user={}".format(user))
6667
zip1_bytes = zip_pem(user.x509cert, f"{user.callsign}_1.pem")
6768
zip2_bytes = zip_pem(user.x509cert, f"{user.callsign}_2.pem")
6869

@@ -85,6 +86,7 @@ async def handle_fragment(request: web.Request) -> web.Response:
8586
async def handle_description(request: web.Request) -> web.Response:
8687
"""Respond with hello_world for user"""
8788
_lang = request.match_info.get("language", "en")
89+
LOGGER.info("Called")
8890

8991
return web.json_response(
9092
{
@@ -102,6 +104,7 @@ async def handle_instructions(request: web.Request) -> web.Response:
102104
check_peer_cert(request)
103105
_lang = request.match_info.get("language", "en")
104106
payload = await request.json()
107+
LOGGER.info("Called with payload={}".format(payload))
105108

106109
return web.json_response(
107110
{

tests/test_enrollment.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,16 @@ async def test_enroll_with_invite_code( # pylint: disable=R0915
590590
assert pfxdata.cert
591591

592592
# Fetch also with alternative URLs
593-
resp = await unauth_client_session.get("/api/v1/enduserpfx/enrollenrique.pfx")
593+
pfxurl = "/api/v1/enduserpfx/enrollenrique.pfx"
594+
LOGGER.debug("Trying: {}".format(pfxurl))
595+
unauth_client_session.headers.update({"Authorization": f"Bearer {enrique_jwt}"})
596+
resp = await unauth_client_session.get(pfxurl)
594597
resp.raise_for_status()
598+
pfxurl2 = f"/api/v1/enduserpfx/enrollenrique_{RMSettings.singleton().deployment_name}.pfx"
599+
LOGGER.debug("Trying: {}".format(pfxurl2))
600+
unauth_client_session.headers.update({"Authorization": f"Bearer {enrique_jwt}"})
595601
resp = await unauth_client_session.get(
596-
f"/api/v1/enduserpfx/enrollenrique_{RMSettings.singleton().deployment_name}.pfx"
602+
pfxurl2,
597603
)
598604
resp.raise_for_status()
599605

0 commit comments

Comments
 (0)