Skip to content

Commit 4f28113

Browse files
fix: remove obsolete Galaxy username check (#105)
* fix: remove Galaxy username check, not needed * test: remove test of galaxy username check
1 parent 907d15b commit 4f28113

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

routers/galaxy_register.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from typing import Annotated, Optional
33

4-
import httpx
54
from fastapi import APIRouter, Header, HTTPException
65
from fastapi.params import Depends
76
from httpx import HTTPStatusError
@@ -12,13 +11,11 @@
1211
from config import Settings, get_settings
1312
from db.models import BiocommonsUser, PlatformEnum
1413
from db.setup import get_db_session
15-
from galaxy.client import GalaxyClient, get_galaxy_client
1614
from register.tokens import create_registration_token, verify_registration_token
1715
from routers.errors import RegistrationRoute
1816
from schemas.biocommons import Auth0UserData, BiocommonsRegisterData
1917
from schemas.galaxy import GalaxyRegistrationData
2018
from schemas.responses import (
21-
FieldError,
2219
RegistrationErrorResponse,
2320
RegistrationResponse,
2421
)
@@ -47,7 +44,6 @@ async def get_registration_token(settings: Settings = Depends(get_settings)):
4744
def register(
4845
registration_data: GalaxyRegistrationData,
4946
settings: Annotated[Settings, Depends(get_settings)],
50-
galaxy_client: Annotated[GalaxyClient, Depends(get_galaxy_client)],
5147
auth0_client: Annotated[Auth0Client, Depends(get_auth0_client)],
5248
db_session: Annotated[Session, Depends(get_db_session)],
5349
registration_token: Optional[str] = Header(None),
@@ -59,19 +55,6 @@ def register(
5955
logger.debug("Registration token verified.")
6056

6157
user_data = BiocommonsRegisterData.from_galaxy_registration(registration_data)
62-
logger.debug("Checking if username exists in Galaxy")
63-
galaxy_username = user_data.username
64-
try:
65-
existing = galaxy_client.username_exists(galaxy_username)
66-
if existing:
67-
username_error = FieldError(field="username", message="Username already exists in Galaxy")
68-
error_response = RegistrationErrorResponse(
69-
message="Username already exists in Galaxy",
70-
field_errors=[username_error]
71-
)
72-
return JSONResponse(status_code=400, content=error_response.model_dump(mode="json"))
73-
except httpx.HTTPError as e:
74-
logger.warning(f"Failed to check username in Galaxy: {e}")
7558

7659
try:
7760
logger.info("Registering user with Auth0")

tests/test_galaxy.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,6 @@ def test_register_requires_token(test_client):
163163
assert resp.json()["detail"] == "Missing registration token"
164164

165165

166-
def test_register_duplicate_galaxy_username(test_client, mock_galaxy_client):
167-
"""
168-
Test we raise an error if the galaxy username is already taken
169-
"""
170-
user_data = GalaxyRegistrationDataFactory.build()
171-
token_resp = test_client.get("/galaxy/register/get-registration-token")
172-
headers = {"registration-token": token_resp.json()["token"]}
173-
mock_galaxy_client.username_exists.return_value = True
174-
resp = test_client.post("/galaxy/register", json=user_data.model_dump(), headers=headers)
175-
assert resp.status_code == 400
176-
details = resp.json()
177-
assert details["message"] == "Username already exists in Galaxy"
178-
assert "username" in details["field_errors"][0]["field"]
179-
180-
181166
def test_register_duplicate_auth0_username(test_client, mock_galaxy_client, mock_auth0_client):
182167
"""Test registration with duplicate Auth0 username"""
183168
user_data = GalaxyRegistrationDataFactory.build()

0 commit comments

Comments
 (0)