Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions scripts/jupyterhub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from playwright.async_api import expect

async def login(page, username, password, transition_timeout=30000):
# Login to JupyterHub
jupyterhub_signin_button = page.locator('//*[@id = "login_submit"]')
await expect(jupyterhub_signin_button).to_be_visible(timeout=transition_timeout)
await page.locator('//*[@id = "username_input"]').fill(username)
await page.locator('//*[@id = "password_input"]').fill(password)
await jupyterhub_signin_button.click()

async def authorize(page, transition_timeout=30000):
# JupyterHub authorizes a service (e.g. BinderHub addon of RDM OSF Integration)
authorize_button = page.locator('//*[@value = "Authorize"]')
await expect(authorize_button).to_be_visible(timeout=transition_timeout)
await authorize_button.click()
51 changes: 46 additions & 5 deletions テスト手順-BinderHub-BinderHubアドオン-Dockerfile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"idp_name_1 = None\n",
"idp_username_1 = None\n",
"idp_password_1 = None\n",
"\n",
"binderhub_auth_mode = 'auto'\n",
"jupyterhub_username = None\n",
"jupyterhub_password = None\n",
"\n",
"default_result_path = None\n",
"close_on_fail = False\n",
"transition_timeout = 60 * 1000\n",
Expand Down Expand Up @@ -49,6 +54,15 @@
" idp_username_1 = input(prompt=f'Username for {idp_name_1}')\n",
"if idp_password_1 is None:\n",
" idp_password_1 = getpass(prompt=f'Password for {idp_username_1}@{idp_name_1}')\n",
"if binderhub_auth_mode == 'jupyterhub':\n",
" if jupyterhub_username is None:\n",
" jupyterhub_username = input(prompt='Username for JupyterHub')\n",
" if jupyterhub_password is None:\n",
" jupyterhub_password = getpass(prompt=f'Password for {jupyterhub_username}@JupyterHub')\n",
" if jupyterhub_username is None or jupyterhub_password is None:\n",
" raise ValueError(\n",
" \"binderhub_auth_mode='jupyterhub' requires jupyterhub_username and jupyterhub_password\"\n",
" )\n",
"if project_name is None:\n",
" project_name = datetime.now().strftime('TEST-BINDERHUB-%Y%m%d%H%M')\n",
"\n",
Expand Down Expand Up @@ -101,7 +115,7 @@
"importlib.reload(scripts.playwright)\n",
"\n",
"from scripts.playwright import *\n",
"from scripts import grdm\n",
"from scripts import grdm, jupyterhub\n",
"\n",
"await init_pw_context(close_on_fail=close_on_fail, last_path=default_result_path)\n"
]
Expand Down Expand Up @@ -277,11 +291,25 @@
"source": [
"async def _step(page):\n",
" await page.locator('//a[contains(text(), \"解析\")]').click()\n",
"\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" launch_button = page.locator('//*[@data-test-binderhub-launch]')\n",
" await expect(open_idp_list.or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(launch_button).to_be_visible(timeout=transition_timeout)\n",
Expand Down Expand Up @@ -428,11 +456,24 @@
"outputs": [],
"source": [
"async def _step(page):\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" start_ipykernel = page.locator(f'//*[@class = \"jp-LauncherCard\" and @title = \"Python 3 (ipykernel)\" and @data-category = \"Notebook\"]')\n",
" await expect(open_idp_list.or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(start_ipykernel).to_be_visible(timeout=transition_timeout)\n",
Expand Down
51 changes: 46 additions & 5 deletions テスト手順-BinderHub-BinderHubアドオン-repo2docker.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"idp_name_1 = None\n",
"idp_username_1 = None\n",
"idp_password_1 = None\n",
"\n",
"binderhub_auth_mode = 'auto'\n",
"jupyterhub_username = None\n",
"jupyterhub_password = None\n",
"\n",
"default_result_path = None\n",
"close_on_fail = False\n",
"project_name = None\n",
Expand Down Expand Up @@ -54,6 +59,15 @@
" idp_username_1 = input(prompt=f'Username for {idp_name_1}')\n",
"if idp_password_1 is None:\n",
" idp_password_1 = getpass(prompt=f'Password for {idp_username_1}@{idp_name_1}')\n",
"if binderhub_auth_mode == 'jupyterhub':\n",
" if jupyterhub_username is None:\n",
" jupyterhub_username = input(prompt='Username for JupyterHub')\n",
" if jupyterhub_password is None:\n",
" jupyterhub_password = getpass(prompt=f'Password for {jupyterhub_username}@JupyterHub')\n",
" if jupyterhub_username is None or jupyterhub_password is None:\n",
" raise ValueError(\n",
" \"binderhub_auth_mode='jupyterhub' requires jupyterhub_username and jupyterhub_password\"\n",
" )\n",
"if project_name is None:\n",
" project_name = datetime.now().strftime('TEST-BINDERHUB-%Y%m%d%H%M')\n",
"\n",
Expand Down Expand Up @@ -105,7 +119,7 @@
"importlib.reload(scripts.playwright)\n",
"\n",
"from scripts.playwright import *\n",
"from scripts import grdm\n",
"from scripts import grdm, jupyterhub\n",
"\n",
"await init_pw_context(close_on_fail=close_on_fail, last_path=default_result_path)\n"
]
Expand Down Expand Up @@ -281,11 +295,25 @@
"source": [
"async def _step(page):\n",
" await page.locator('//a[contains(text(), \"解析\")]').click()\n",
"\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" launch_button = page.locator('//*[@data-test-binderhub-launch]')\n",
" await expect(open_idp_list.or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(launch_button).to_be_visible(timeout=transition_timeout)\n",
Expand Down Expand Up @@ -678,11 +706,24 @@
"outputs": [],
"source": [
"async def _step(page):\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" start_ipykernel = page.locator(f'//*[@class = \"jp-LauncherCard\" and @title = \"Python 3 (ipykernel)\" and @data-category = \"Notebook\"]')\n",
" await expect(open_idp_list.or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(start_ipykernel).to_be_visible(timeout=transition_timeout)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"idp_name_1 = None\n",
"idp_username_1 = None\n",
"idp_password_1 = None\n",
"\n",
"binderhub_auth_mode = 'auto'\n",
"jupyterhub_username = None\n",
"jupyterhub_password = None\n",
"\n",
"default_result_path = None\n",
"close_on_fail = False\n",
"transition_timeout = 60 * 1000\n",
Expand Down Expand Up @@ -49,6 +54,15 @@
" idp_username_1 = input(prompt=f'Username for {idp_name_1}')\n",
"if idp_password_1 is None:\n",
" idp_password_1 = getpass(prompt=f'Password for {idp_username_1}@{idp_name_1}')\n",
"if binderhub_auth_mode == 'jupyterhub':\n",
" if jupyterhub_username is None:\n",
" jupyterhub_username = input(prompt='Username for JupyterHub')\n",
" if jupyterhub_password is None:\n",
" jupyterhub_password = getpass(prompt=f'Password for {jupyterhub_username}@JupyterHub')\n",
" if jupyterhub_username is None or jupyterhub_password is None:\n",
" raise ValueError(\n",
" \"binderhub_auth_mode='jupyterhub' requires jupyterhub_username and jupyterhub_password\"\n",
" )\n",
"if project_name is None:\n",
" project_name = datetime.now().strftime('TEST-BINDERHUB-%Y%m%d%H%M')\n",
"\n",
Expand Down Expand Up @@ -99,7 +113,7 @@
"importlib.reload(scripts.playwright)\n",
"\n",
"from scripts.playwright import *\n",
"from scripts import grdm\n",
"from scripts import grdm, jupyterhub\n",
"\n",
"await init_pw_context(close_on_fail=close_on_fail, last_path=default_result_path)\n"
]
Expand Down Expand Up @@ -314,11 +328,25 @@
"source": [
"async def _step(page):\n",
" await page.locator('//a[contains(text(), \"解析\")]').click()\n",
"\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" launch_button = page.locator('//*[@data-test-binderhub-launch]')\n",
" await expect(open_idp_list.or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(launch_button)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(launch_button).to_be_visible(timeout=transition_timeout)\n",
Expand Down Expand Up @@ -408,11 +436,24 @@
"outputs": [],
"source": [
"async def _step(page):\n",
" jh_login = page.locator('//*[@id = \"login_submit\"]')\n",
" open_idp_list = page.locator('//*[@id = \"dropdown_img\"]')\n",
" start_ipykernel = page.locator(f'//*[@class = \"jp-LauncherCard\" and @title = \"Python 3 (ipykernel)\" and @data-category = \"Notebook\"]')\n",
" await expect(open_idp_list.or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await open_idp_list.is_visible():\n",
" await expect(jh_login.or_(open_idp_list).or_(start_ipykernel)).to_be_visible(timeout=transition_timeout)\n",
"\n",
" if await jh_login.is_visible():\n",
" if binderhub_auth_mode == 'sso':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='sso' but JupyterHub login form appeared\"\n",
" )\n",
" await jupyterhub.login(page, jupyterhub_username, jupyterhub_password, transition_timeout)\n",
" await jupyterhub.authorize(page, transition_timeout)\n",
" elif await open_idp_list.is_visible():\n",
" if binderhub_auth_mode == 'jupyterhub':\n",
" raise AssertionError(\n",
" \"binderhub_auth_mode='jupyterhub' but SSO Discovery Service appeared\"\n",
" )\n",
" await grdm.login(page, idp_name_1, idp_username_1, idp_password_1, transition_timeout=transition_timeout)\n",
"\n",
" await expect(start_ipykernel).to_be_visible(timeout=transition_timeout)\n",
Expand Down
Loading
Loading