diff --git a/tljh_repo2docker/app.py b/tljh_repo2docker/app.py index 354cb27..41060c7 100644 --- a/tljh_repo2docker/app.py +++ b/tljh_repo2docker/app.py @@ -146,12 +146,11 @@ def _default_log_level(self): repo_providers = List( default_value=[ {"label": "Git", "value": "git"}, - {"label": "GitHub", "value": "gh"}, - {"label": "Gitlab", "value": "gl"}, ], trait=Dict, help=""" - Dict of available repo providers in the form of {"label":"value"} + Dict of available repo providers in the form of {"label":"value"}. + The references are taken from the binderhub documentation """, config=True, ) diff --git a/tljh_repo2docker/base.py b/tljh_repo2docker/base.py index afedcc2..e825cf9 100644 --- a/tljh_repo2docker/base.py +++ b/tljh_repo2docker/base.py @@ -3,7 +3,8 @@ import os from contextlib import _AsyncGeneratorContextManager from http.client import responses -from typing import Callable, Dict, List, Optional, Tuple +import sys +from typing import Any, Callable, Dict, List, Optional, Tuple from httpx import AsyncClient from jinja2 import Template @@ -17,6 +18,10 @@ from .model import UserModel +if sys.version_info >= (3, 9): + AsyncSessionContextFactory = Callable[[], _AsyncGeneratorContextManager[AsyncSession]] +else: + AsyncSessionContextFactory = Any def require_admin_role(func): """decorator to require admin role to perform an action""" @@ -179,7 +184,7 @@ def use_binderhub(self) -> bool: def get_db_handlers( self, ) -> Tuple[ - Optional[Callable[[], _AsyncGeneratorContextManager[AsyncSession]]], + Optional[AsyncSessionContextFactory], Optional[ImagesDatabaseManager], ]: """ diff --git a/tljh_repo2docker/tests/conftest.py b/tljh_repo2docker/tests/conftest.py index 602f765..d6e975b 100644 --- a/tljh_repo2docker/tests/conftest.py +++ b/tljh_repo2docker/tests/conftest.py @@ -63,7 +63,7 @@ async def app(hub_app): { "description": "Role for tljh_repo2docker service", "name": "tljh-repo2docker-service", - "scopes": ["read:users", "read:servers", "read:roles:users"], + "scopes": ["read:users", "read:roles:users", "admin:servers"], "services": ["tljh_repo2docker"], } ] diff --git a/tljh_repo2docker/tests/test_images.py b/tljh_repo2docker/tests/test_images.py index e90aff0..8bff25f 100644 --- a/tljh_repo2docker/tests/test_images.py +++ b/tljh_repo2docker/tests/test_images.py @@ -15,7 +15,7 @@ async def test_images_list_admin(app): ) r.raise_for_status() assert ( - '{"images": [], "default_mem_limit": "None", "default_cpu_limit":"None", "machine_profiles": []}' + '{"repo_providers": [{"label": "Git", "value": "git"}], "use_binderhub": false, "images": [], "default_mem_limit": "None", "default_cpu_limit":"None", "machine_profiles": []}' in r.text ) diff --git a/ui-tests/binderhub_config.py b/ui-tests/binderhub_config.py index 440ab02..95d1226 100644 --- a/ui-tests/binderhub_config.py +++ b/ui-tests/binderhub_config.py @@ -19,17 +19,19 @@ c.BinderHub.auth_enabled = True c.BinderHub.enable_api_only_mode = True -c.BinderHub.use_registry = os.getenv("BINDERHUB_USE_REGISTRY", False) -c.BinderHub.image_prefix = os.getenv( - "BINDERHUB_IMAGE_PREFIX", "" -) # https://binderhub.readthedocs.io/en/latest/zero-to-binderhub/setup-binderhub.html#id2 -c.DockerRegistry.auth_config_url = "https://index.docker.io/v1/" -c.BuildExecutor.push_secret = "*" # +use_registry = bool(os.getenv("BINDERHUB_USE_REGISTRY", False)) +if use_registry: + c.BinderHub.use_registry = use_registry + c.BinderHub.image_prefix = os.getenv( + "BINDERHUB_IMAGE_PREFIX", "" + ) # https://binderhub.readthedocs.io/en/latest/zero-to-binderhub/setup-binderhub.html#id2 + c.DockerRegistry.auth_config_url = "https://index.docker.io/v1/" + + c.BuildExecutor.push_secret = "*" # c.BinderHub.builder_required = False c.BinderHub.build_class = LocalRepo2dockerBuild -c.BinderHub.push_secret = "" c.BinderHub.launch_quota_class = LaunchQuota c.BinderHub.hub_url_local = "http://localhost:8000" diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/admin-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/admin-linux.png new file mode 100644 index 0000000..f1bd625 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/admin-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environment-console-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environment-console-linux.png new file mode 100644 index 0000000..d517fcf Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environment-console-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environment-dialog-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environment-dialog-linux.png new file mode 100644 index 0000000..9b4a5d7 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environment-dialog-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environment-list-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environment-list-linux.png new file mode 100644 index 0000000..966517a Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environment-list-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environment-remove-confirm-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environment-remove-confirm-linux.png new file mode 100644 index 0000000..2d9a6f5 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environment-remove-confirm-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environment-removed-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environment-removed-linux.png new file mode 100644 index 0000000..185a854 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environment-removed-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/environments-page-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/environments-page-linux.png new file mode 100644 index 0000000..185a854 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/environments-page-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/login-page-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/login-page-linux.png new file mode 100644 index 0000000..17033c5 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/login-page-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/running-servers-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/running-servers-linux.png new file mode 100644 index 0000000..c1d35b0 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/running-servers-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/server-remove-confirm-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/server-remove-confirm-linux.png new file mode 100644 index 0000000..083a256 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/server-remove-confirm-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/server-removed-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/server-removed-linux.png new file mode 100644 index 0000000..a4ea831 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/server-removed-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/servers-dialog-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/servers-dialog-linux.png new file mode 100644 index 0000000..474517f Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/servers-dialog-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/servers-page-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/servers-page-linux.png new file mode 100644 index 0000000..f1bd625 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/servers-page-linux.png differ diff --git a/ui-tests/binderhub_snapshots/ui.test.ts/user-linux.png b/ui-tests/binderhub_snapshots/ui.test.ts/user-linux.png new file mode 100644 index 0000000..0ba2fe8 Binary files /dev/null and b/ui-tests/binderhub_snapshots/ui.test.ts/user-linux.png differ diff --git a/ui-tests/tests/ui.test.ts b/ui-tests/tests/ui.test.ts index d4fb46a..abddfe4 100644 --- a/ui-tests/tests/ui.test.ts +++ b/ui-tests/tests/ui.test.ts @@ -98,10 +98,9 @@ test.describe('tljh_repo2docker UI Tests', () => { .getByRole('button') .first() .click(); - await page.waitForSelector( - 'span:has-text("Successfully tagged python-env:HEAD")', - { timeout: 600000 } - ); + await page.waitForSelector('span:has-text("Successfully tagged")', { + timeout: 600000 + }); expect(await page.screenshot()).toMatchSnapshot('environment-console.png', { maxDiffPixelRatio: 0.05 });