Skip to content
Snippets Groups Projects
Verified Commit 312a866e authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Fix Dockerfile and make gravatar url in use schema mandatory

#13
parent d4be6360
No related branches found
No related tags found
1 merge request!13Resolve "Fix typo in Dockerfile"
Pipeline #55051 passed
......@@ -18,7 +18,7 @@ WORKDIR /home/worker/code
ENV PYTHONPATH=/home/worker/code
ENV PATH="/home/worker/.local/bin:${PATH}"
COPY ../start_service_uvicorn.sh ./entrypoint.sh
COPY ./start_service_uvicorn.sh ./entrypoint.sh
COPY scripts/prestart.sh ./prestart.sh
CMD ["./entrypoint.sh"]
......
FROM python:3.12-slim
ENV PORT=8000
ENV OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS="set-cookie"
EXPOSE $PORT
WORKDIR /app/
ENV PYTHONPATH=/app
......
......@@ -45,12 +45,14 @@ class UserOutExtended(UserOut, UserRoles):
invitation_token_created_at: int | None = Field(
None, description="Timestamp when the invitation token was created as UNIX timestamp"
)
gravatar_url: URL | None = Field(default=None, description="URL to the gravatar avatar based on the users email")
gravatar_url: URL = Field(description="URL to the gravatar avatar based on the users email")
@staticmethod
def generate_gravatar_url(email: str | None) -> AnyHttpUrl | None:
def generate_gravatar_url(email: str | None) -> AnyHttpUrl:
if email is None:
return None
return AnyHttpUrl(
"https://gravatar.com/avatar/87a8c45825eb709ee8e453d2c0f8154e1b9bf4b45bb9b81b7662177340aa9d38"
)
return AnyHttpUrl(f"https://gravatar.com/avatar/{sha256(email.strip().lower().encode('utf-8')).hexdigest()}")
@staticmethod
......
......@@ -3,7 +3,10 @@ from clowm.schemas.user import UserOutExtended
class TestGravatar:
def test_gravatar_url_for_none_email(self) -> None:
assert UserOutExtended.generate_gravatar_url(email=None) is None
assert (
str(UserOutExtended.generate_gravatar_url(email=None))
== "https://gravatar.com/avatar/87a8c45825eb709ee8e453d2c0f8154e1b9bf4b45bb9b81b7662177340aa9d38"
)
def test_gravatar_url_for_email(self) -> None:
assert (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment