-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b186da
commit c6a1c63
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from django.test import tag | ||
|
||
from playwright.async_api import expect | ||
|
||
from openarchiefbeheer.utils.tests.e2e import PlaywrightTestCase, browser_page | ||
|
||
|
||
@tag("e2e") | ||
class OIDCLoginTest(PlaywrightTestCase): | ||
fixtures = ["permissions.json", "oidc_config_test.json"] | ||
|
||
async def test_login_admin_superuser_with_oidc(self): | ||
async with browser_page() as page: | ||
await page.goto(f"{self.live_server_url}/admin") | ||
|
||
link = page.get_by_role("link", name="Login with OIDC") | ||
|
||
await expect(link).to_be_visible() | ||
|
||
await link.click() | ||
|
||
username_field = page.get_by_role("textbox", name="username") | ||
await username_field.fill( | ||
"john_doe" | ||
) # configured in the Keycloak fixture as superuser | ||
|
||
password_field = page.get_by_role("textbox", name="password") | ||
await password_field.fill("aNic3Passw0rd") | ||
|
||
login_button = page.get_by_role("button", name="Sign In") | ||
await login_button.click() | ||
|
||
await page.wait_for_url(f"{self.live_server_url}/admin/") | ||
|
||
configuration_link = page.get_by_role("link", name="API configuration") | ||
await expect(configuration_link).to_be_visible() | ||
|
||
async def test_login_admin_staff_with_oidc(self): | ||
async with browser_page() as page: | ||
await page.goto(f"{self.live_server_url}/admin") | ||
|
||
link = page.get_by_role("link", name="Login with OIDC") | ||
|
||
await expect(link).to_be_visible() | ||
|
||
await link.click() | ||
|
||
username_field = page.get_by_role("textbox", name="username") | ||
await username_field.fill( | ||
"alice_doe" | ||
) # configured in the Keycloak fixture as record manager | ||
|
||
password_field = page.get_by_role("textbox", name="password") | ||
await password_field.fill("aNic3Passw0rd") | ||
|
||
login_button = page.get_by_role("button", name="Sign In") | ||
await login_button.click() | ||
|
||
await page.wait_for_url(f"{self.live_server_url}/admin/") | ||
|
||
page_text = page.get_by_text("You don't have permission to") | ||
await expect(page_text).to_be_visible() | ||
|
||
async def test_login_app_with_oidc(self): | ||
async with browser_page() as page: | ||
await page.goto(self.live_server_url) | ||
await page.wait_for_url( | ||
f"{self.live_server_url}/login?next=/destruction-lists" | ||
) | ||
|
||
login_button = page.get_by_text("Organisatie login") | ||
|
||
await login_button.click() | ||
|
||
username_field = page.get_by_role("textbox", name="username") | ||
await username_field.fill( | ||
"alice_doe" | ||
) # configured in the Keycloak fixture as record manager | ||
|
||
password_field = page.get_by_role("textbox", name="password") | ||
await password_field.fill("aNic3Passw0rd") | ||
|
||
await page.wait_for_url(f"{self.live_server_url}/destruction-lists") | ||
|
||
page_text = page.get_by_text("Vernietigingslijsten") | ||
await expect(page_text).to_be_visible() |