Refactor frontend views
All checks were successful
Build and push image / build-containers (push) Successful in 10m14s

This commit is contained in:
2025-06-14 21:56:17 +02:00
parent b3debd3ed2
commit bce372a1d1
32 changed files with 1230 additions and 458 deletions

View File

@ -7,6 +7,7 @@ rest of the tests.
import pytest
import httpx
from sshecret.backend import SshecretBackend
from sshecret.backend.models import ClientFilter
from .clients import create_test_client
@ -57,3 +58,21 @@ async def test_create_secret(backend_api: SshecretBackend) -> None:
assert secret is not None
assert secret == "encrypted_secret"
@pytest.mark.parametrize("offset,limit", [(0, 10), (0, 20), (10, 1)])
@pytest.mark.asyncio
async def test_client_filtering(backend_api: SshecretBackend, offset: int, limit: int) -> None:
"""Test filtering on the backend API."""
# We need to create 100 test clients.
for x in range(20):
client_name = f"test-{x}"
test_client = create_test_client(client_name)
await backend_api.create_client(client_name, test_client.public_key)
client_filter = ClientFilter(offset=offset, limit=limit)
clients = await backend_api.get_clients(client_filter)
assert len(clients) == limit
first_client = clients[0]
expected_name = f"test-{offset}"
assert first_client.name == expected_name