Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/storage/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@
"type": "string",
"format": "path",
"title": "Display Path",
"description": "the path to display with UUID replaced"
"description": "the path to display with UUID replaced (URL Encoded by parts as names may contain '/')"
},
"file_meta_data": {
"anyOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12389,7 +12389,8 @@ components:
type: string
format: path
title: Display Path
description: the path to display with UUID replaced
description: the path to display with UUID replaced (URL Encoded by parts
as names may contain '/')
file_meta_data:
anyOf:
- $ref: '#/components/schemas/FileMetaDataGet'
Expand Down
32 changes: 32 additions & 0 deletions services/web/server/tests/unit/with_dbs/01/test_api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
from aiohttp.test_utils import TestClient
from faker import Faker
from models_library.products import ProductName
from pytest_mock import MockerFixture
from pytest_simcore.helpers.assert_checks import assert_status
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
from pytest_simcore.helpers.typing_env import EnvVarsDict
from pytest_simcore.helpers.webserver_login import NewUser, UserInfoDict
from servicelib.aiohttp import status
from servicelib.aiohttp.application_keys import APP_SETTINGS_KEY
from simcore_service_webserver.api_keys import _repository as repo
from simcore_service_webserver.api_keys._models import ApiKey
from simcore_service_webserver.api_keys._service import (
get_or_create_api_key,
prune_expired_api_keys,
)
from simcore_service_webserver.application_settings import GarbageCollectorSettings
from simcore_service_webserver.db.models import UserRole


Expand Down Expand Up @@ -215,3 +220,30 @@ async def test_get_not_existing_api_key(

if not errors:
assert data is None


@pytest.fixture
async def app_environment(
app_environment: EnvVarsDict,
monkeypatch: pytest.MonkeyPatch,
) -> EnvVarsDict:
return app_environment | setenvs_from_dict(
monkeypatch,
{
"WEBSERVER_GARBAGE_COLLECTOR": '{"GARBAGE_COLLECTOR_INTERVAL_S": 30, "GARBAGE_COLLECTOR_PRUNE_APIKEYS_INTERVAL_S": 1}'
},
)


async def test_prune_expired_api_keys_task_is_triggered(
app_environment: EnvVarsDict, mocker: MockerFixture, client: TestClient
):
mock = mocker.patch(
"simcore_service_webserver.api_keys._service._repository.prune_expired"
)
settings = client.server.app[ # type: ignore
APP_SETTINGS_KEY
].WEBSERVER_GARBAGE_COLLECTOR
assert isinstance(settings, GarbageCollectorSettings)
await asyncio.sleep(2 * settings.GARBAGE_COLLECTOR_PRUNE_APIKEYS_INTERVAL_S)
mock.assert_called()
Loading