Commit f5412658 authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat: add validation for products field in CreateApiClientRequest and update...

feat: add validation for products field in CreateApiClientRequest and update tests for empty products case
parent c5f05072
Loading
Loading
Loading
Loading
+5 −1
Changes for portal-gui/src/components/api-clients/api-client-secret-dialog.tsx: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -23,7 +23,11 @@ export function ApiClientSecretDialog({

  return (
    <Dialog open onOpenChange={(open) => !open && onClose()}>
      <DialogContent className="max-h-[90vh] overflow-y-auto sm:max-w-2xl">
      <DialogContent
        className="max-h-[90vh] overflow-y-auto sm:max-w-2xl"
        onEscapeKeyDown={(event) => event.preventDefault()}
        onInteractOutside={(event) => event.preventDefault()}
      >
        <DialogHeader>
          <DialogTitle>{client.name} created</DialogTitle>
          <DialogDescription>
+1 −1
Changes for src/portal_service/api/api_clients/schemas.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ class CreateApiClientRequest(BaseModel):
    # The limits are the column sizes of the api_clients table.
    name: str = Field(min_length=1, max_length=100)
    description: str = Field(default="", max_length=500)
    products: frozenset[str]
    products: frozenset[str] = Field(min_length=1)


class ApiClientResponse(BaseModel):
+2 −1
Changes for tests/unit/test_api_client_routes.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -125,8 +125,9 @@ def test_a_repeated_name_and_the_limit_are_conflicts(client: TestClient) -> None
        {**BODY, "name": "x" * 101},
        {**BODY, "description": "x" * 501},
        {"name": "No products field"},
        {**BODY, "products": []},
    ],
    ids=["empty name", "long name", "long description", "no products"],
    ids=["empty name", "long name", "long description", "no products", "empty products"],
)
def test_invalid_requests_are_rejected_before_anything_is_created(
    client: TestClient, s: Setup, body: dict[str, Any]