e2e: cleanup tests, remove XPATH selectors
This commit is contained in:
parent
67b69cb5d3
commit
e54b98a80e
|
@ -104,8 +104,7 @@ class TestFlowsEnroll(SeleniumTestCase):
|
||||||
|
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, "foo",
|
||||||
"foo",
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
||||||
|
@ -205,16 +204,11 @@ class TestFlowsEnroll(SeleniumTestCase):
|
||||||
self.driver.switch_to.window(self.driver.window_handles[0])
|
self.driver.switch_to.window(self.driver.window_handles[0])
|
||||||
|
|
||||||
# We're now logged in
|
# We're now logged in
|
||||||
self.wait.until(
|
self.wait.until(ec.presence_of_element_located((By.ID, "user-settings")))
|
||||||
ec.presence_of_element_located(
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
(By.XPATH, "//a[contains(@href, '/-/user/')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, "foo",
|
||||||
"foo",
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
||||||
|
|
|
@ -21,6 +21,5 @@ class TestFlowsLogin(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, USER().username,
|
||||||
USER().username,
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,6 +10,7 @@ from django_otp.plugins.otp_static.models import StaticDevice, StaticToken
|
||||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
|
|
||||||
from e2e.utils import USER, SeleniumTestCase
|
from e2e.utils import USER, SeleniumTestCase
|
||||||
from passbook.flows.models import Flow, FlowStageBinding
|
from passbook.flows.models import Flow, FlowStageBinding
|
||||||
|
@ -45,9 +46,9 @@ class TestFlowsOTP(SeleniumTestCase):
|
||||||
totp = TOTP(device.bin_key, device.step, device.t0, device.digits, device.drift)
|
totp = TOTP(device.bin_key, device.step, device.t0, device.digits, device.drift)
|
||||||
self.driver.find_element(By.ID, "id_code").send_keys(totp.token())
|
self.driver.find_element(By.ID, "id_code").send_keys(totp.token())
|
||||||
self.driver.find_element(By.ID, "id_code").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_code").send_keys(Keys.ENTER)
|
||||||
|
self.wait_for_url(self.url("passbook_core:overview"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, USER().username,
|
||||||
USER().username,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_otp_totp_setup(self):
|
def test_otp_totp_setup(self):
|
||||||
|
@ -61,12 +62,11 @@ class TestFlowsOTP(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, USER().username,
|
||||||
USER().username,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
|
|
||||||
self.driver.find_element(By.LINK_TEXT, "Time-based OTP").click()
|
self.driver.find_element(By.LINK_TEXT, "Time-based OTP").click()
|
||||||
|
@ -78,9 +78,8 @@ class TestFlowsOTP(SeleniumTestCase):
|
||||||
By.CSS_SELECTOR, ".pf-c-card__body a.pf-c-button"
|
By.CSS_SELECTOR, ".pf-c-card__body a.pf-c-button"
|
||||||
).click()
|
).click()
|
||||||
|
|
||||||
otp_uri = self.driver.find_element(
|
self.wait.until(ec.presence_of_element_located((By.ID, "qr")))
|
||||||
By.CSS_SELECTOR, "#flow-body > div > form > div:nth-child(3) > div"
|
otp_uri = self.driver.find_element(By.ID, "qr").get_attribute("data-otpuri")
|
||||||
).get_attribute("aria-label")
|
|
||||||
|
|
||||||
# Parse the OTP URI, extract the secret and get the next token
|
# Parse the OTP URI, extract the secret and get the next token
|
||||||
otp_args = urlparse(otp_uri)
|
otp_args = urlparse(otp_uri)
|
||||||
|
@ -109,12 +108,11 @@ class TestFlowsOTP(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, USER().username,
|
||||||
USER().username,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
|
|
||||||
self.driver.find_element(By.LINK_TEXT, "Static OTP").click()
|
self.driver.find_element(By.LINK_TEXT, "Static OTP").click()
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TestFlowsStageSetup(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click()
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
self.driver.find_element(By.LINK_TEXT, "Change password").click()
|
self.driver.find_element(By.LINK_TEXT, "Change password").click()
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(new_password)
|
self.driver.find_element(By.ID, "id_password").send_keys(new_password)
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TestProviderOAuth2Github(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
self.wait_for_url("http://localhost:3000/?orgId=1")
|
self.wait_for_url("http://localhost:3000/?orgId=1")
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/profile')]").click()
|
self.driver.get("http://localhost:3000/profile")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
||||||
USER().username,
|
USER().username,
|
||||||
|
@ -142,17 +142,12 @@ class TestProviderOAuth2Github(SeleniumTestCase):
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertEqual(
|
||||||
app.name,
|
app.name, self.driver.find_element(By.ID, "application-name").text,
|
||||||
self.driver.find_element(
|
|
||||||
By.XPATH, "/html/body/div[2]/div/main/div/form/div[2]/p[1]"
|
|
||||||
).text,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"GitHub Compatibility: Access you Email addresses",
|
"GitHub Compatibility: Access you Email addresses",
|
||||||
self.driver.find_element(
|
self.driver.find_element(By.ID, "scope-user:email").text,
|
||||||
By.XPATH, "/html/body/div[2]/div/main/div/form/div[2]/ul/li[1]"
|
|
||||||
).text,
|
|
||||||
)
|
)
|
||||||
self.driver.find_element(
|
self.driver.find_element(
|
||||||
By.CSS_SELECTOR,
|
By.CSS_SELECTOR,
|
||||||
|
@ -163,7 +158,7 @@ class TestProviderOAuth2Github(SeleniumTestCase):
|
||||||
).click()
|
).click()
|
||||||
|
|
||||||
self.wait_for_url("http://localhost:3000/?orgId=1")
|
self.wait_for_url("http://localhost:3000/?orgId=1")
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/profile')]").click()
|
self.driver.get("http://localhost:3000/profile")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
||||||
USER().username,
|
USER().username,
|
||||||
|
|
|
@ -154,7 +154,8 @@ class TestProviderOAuth2OAuth(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/profile')]").click()
|
self.wait_for_url("http://localhost:3000/?orgId=1")
|
||||||
|
self.driver.get("http://localhost:3000/profile")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
||||||
USER().name,
|
USER().name,
|
||||||
|
@ -212,7 +213,8 @@ class TestProviderOAuth2OAuth(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/profile')]").click()
|
self.wait_for_url("http://localhost:3000/?orgId=1")
|
||||||
|
self.driver.get("http://localhost:3000/profile")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
||||||
USER().name,
|
USER().name,
|
||||||
|
@ -235,7 +237,7 @@ class TestProviderOAuth2OAuth(SeleniumTestCase):
|
||||||
).get_attribute("value"),
|
).get_attribute("value"),
|
||||||
USER().email,
|
USER().email,
|
||||||
)
|
)
|
||||||
self.driver.find_element(By.CSS_SELECTOR, "[href='/logout']").click()
|
self.driver.get("http://localhost:3000/logout")
|
||||||
self.wait_for_url(
|
self.wait_for_url(
|
||||||
self.url(
|
self.url(
|
||||||
"passbook_providers_oauth2:end-session",
|
"passbook_providers_oauth2:end-session",
|
||||||
|
@ -279,11 +281,8 @@ class TestProviderOAuth2OAuth(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertEqual(
|
||||||
app.name,
|
app.name, self.driver.find_element(By.ID, "application-name").text,
|
||||||
self.driver.find_element(
|
|
||||||
By.XPATH, "/html/body/div[2]/div/main/div/form/div[2]/p[1]"
|
|
||||||
).text,
|
|
||||||
)
|
)
|
||||||
self.wait.until(
|
self.wait.until(
|
||||||
ec.presence_of_element_located((By.CSS_SELECTOR, "[type=submit]"))
|
ec.presence_of_element_located((By.CSS_SELECTOR, "[type=submit]"))
|
||||||
|
@ -291,12 +290,9 @@ class TestProviderOAuth2OAuth(SeleniumTestCase):
|
||||||
sleep(1)
|
sleep(1)
|
||||||
self.driver.find_element(By.CSS_SELECTOR, "[type=submit]").click()
|
self.driver.find_element(By.CSS_SELECTOR, "[type=submit]").click()
|
||||||
|
|
||||||
self.wait.until(
|
self.wait_for_url("http://localhost:3000/?orgId=1")
|
||||||
ec.presence_of_element_located(
|
self.driver.get("http://localhost:3000/profile")
|
||||||
(By.XPATH, "//a[contains(@href, '/profile')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/profile')]").click()
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
self.driver.find_element(By.CLASS_NAME, "page-header__title").text,
|
||||||
USER().name,
|
USER().name,
|
||||||
|
|
|
@ -200,11 +200,8 @@ class TestProviderOAuth2OIDC(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertEqual(
|
||||||
app.name,
|
app.name, self.driver.find_element(By.ID, "application-name").text,
|
||||||
self.driver.find_element(
|
|
||||||
By.XPATH, "/html/body/div[2]/div/main/div/form/div[2]/p[1]"
|
|
||||||
).text,
|
|
||||||
)
|
)
|
||||||
self.wait.until(
|
self.wait.until(
|
||||||
ec.presence_of_element_located((By.CSS_SELECTOR, "[type=submit]"))
|
ec.presence_of_element_located((By.CSS_SELECTOR, "[type=submit]"))
|
||||||
|
|
|
@ -93,7 +93,7 @@ class TestProviderSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.wait_for_url("http://localhost:9009/")
|
self.wait_for_url("http://localhost:9009/")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "/html/body/pre").text,
|
self.driver.find_element(By.CSS_SELECTOR, "pre").text,
|
||||||
f"Hello, {USER().name}!",
|
f"Hello, {USER().name}!",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,17 +124,14 @@ class TestProviderSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
self.driver.find_element(By.ID, "id_password").send_keys(USER().username)
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.assertIn(
|
self.assertEqual(
|
||||||
app.name,
|
app.name, self.driver.find_element(By.ID, "application-name").text,
|
||||||
self.driver.find_element(
|
|
||||||
By.XPATH, "/html/body/div[2]/div/main/div/form/div[2]/p[1]"
|
|
||||||
).text,
|
|
||||||
)
|
)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
self.driver.find_element(By.CSS_SELECTOR, "[type=submit]").click()
|
self.driver.find_element(By.CSS_SELECTOR, "[type=submit]").click()
|
||||||
self.wait_for_url("http://localhost:9009/")
|
self.wait_for_url("http://localhost:9009/")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "/html/body/pre").text,
|
self.driver.find_element(By.CSS_SELECTOR, "pre").text,
|
||||||
f"Hello, {USER().name}!",
|
f"Hello, {USER().name}!",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -172,7 +169,7 @@ class TestProviderSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
||||||
self.wait_for_url("http://localhost:9009/")
|
self.wait_for_url("http://localhost:9009/")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "/html/body/pre").text,
|
self.driver.find_element(By.CSS_SELECTOR, "pre").text,
|
||||||
f"Hello, {USER().name}!",
|
f"Hello, {USER().name}!",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -145,8 +145,7 @@ class TestSourceOAuth2(SeleniumTestCase):
|
||||||
|
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, "foo",
|
||||||
"foo",
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
||||||
|
@ -199,7 +198,7 @@ class TestSourceOAuth2(SeleniumTestCase):
|
||||||
"""test OAuth Source With With OIDC (enroll and authenticate again)"""
|
"""test OAuth Source With With OIDC (enroll and authenticate again)"""
|
||||||
self.test_oauth_enroll()
|
self.test_oauth_enroll()
|
||||||
# We're logged in at the end of this, log out and re-login
|
# We're logged in at the end of this, log out and re-login
|
||||||
self.driver.find_element(By.CSS_SELECTOR, "[aria-label=logout]").click()
|
self.driver.find_element(By.ID, "logout").click()
|
||||||
|
|
||||||
self.wait.until(
|
self.wait.until(
|
||||||
ec.presence_of_element_located(
|
ec.presence_of_element_located(
|
||||||
|
@ -229,8 +228,7 @@ class TestSourceOAuth2(SeleniumTestCase):
|
||||||
|
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, "foo",
|
||||||
"foo",
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
self.driver.find_element(By.ID, "id_username").get_attribute("value"), "foo"
|
||||||
|
@ -324,8 +322,7 @@ class TestSourceOAuth1(SeleniumTestCase):
|
||||||
|
|
||||||
self.wait_for_url(self.url("passbook_core:user-settings"))
|
self.wait_for_url(self.url("passbook_core:user-settings"))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
self.driver.find_element(By.ID, "user-settings").text, "example-user",
|
||||||
"example-user",
|
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.driver.find_element(By.ID, "id_username").get_attribute("value"),
|
self.driver.find_element(By.ID, "id_username").get_attribute("value"),
|
||||||
|
|
|
@ -130,12 +130,8 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
# Wait until we're logged in
|
# Wait until we're logged in
|
||||||
self.wait.until(
|
self.wait.until(ec.presence_of_element_located((By.ID, "user-settings")))
|
||||||
ec.presence_of_element_located(
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
(By.XPATH, "//a[contains(@href, '/-/user/')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
# Wait until we've loaded the user info page
|
||||||
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
||||||
|
@ -183,12 +179,8 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
# Wait until we're logged in
|
# Wait until we're logged in
|
||||||
self.wait.until(
|
self.wait.until(ec.presence_of_element_located((By.ID, "user-settings")))
|
||||||
ec.presence_of_element_located(
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
(By.XPATH, "//a[contains(@href, '/-/user/')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
# Wait until we've loaded the user info page
|
||||||
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
||||||
|
@ -234,12 +226,8 @@ class TestSourceSAML(SeleniumTestCase):
|
||||||
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
# Wait until we're logged in
|
# Wait until we're logged in
|
||||||
self.wait.until(
|
self.wait.until(ec.presence_of_element_located((By.ID, "user-settings")))
|
||||||
ec.presence_of_element_located(
|
self.driver.find_element(By.ID, "user-settings").click()
|
||||||
(By.XPATH, "//a[contains(@href, '/-/user/')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").click()
|
|
||||||
|
|
||||||
# Wait until we've loaded the user info page
|
# Wait until we've loaded the user info page
|
||||||
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
self.wait.until(ec.presence_of_element_located((By.ID, "id_username")))
|
||||||
|
|
|
@ -44,12 +44,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pf-c-page__header-tools">
|
<div class="pf-c-page__header-tools">
|
||||||
<div class="pf-c-page__header-tools-group pf-m-icons">
|
<div class="pf-c-page__header-tools-group pf-m-icons">
|
||||||
<a href="{% url 'passbook_flows:default-invalidation' %}" class="pf-c-button pf-m-plain" type="button" aria-label="logout">
|
<a href="{% url 'passbook_flows:default-invalidation' %}" class="pf-c-button pf-m-plain" type="button" id="logout">
|
||||||
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
|
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="pf-c-page__header-tools-group">
|
<div class="pf-c-page__header-tools-group">
|
||||||
<a href="{% url 'passbook_core:user-settings' %}" class="pf-c-button">
|
<a href="{% url 'passbook_core:user-settings' %}" id="user-settings" class="pf-c-button">
|
||||||
{{ user.username }}
|
{{ user.username }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
<div class="pf-c-form__group">
|
<div class="pf-c-form__group">
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans with name=context.application.name %}
|
{% blocktrans with name=context.application.name %}
|
||||||
You're about to sign into {{ name }}.
|
You're about to sign into <strong id="application-name">{{ name }}</strong>.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
<p>{% trans "Application requires following permissions" %}</p>
|
<p>{% trans "Application requires following permissions" %}</p>
|
||||||
<ul class="pf-c-list">
|
<ul class="pf-c-list" id="scopes">
|
||||||
{% for scope in context.scope_descriptions %}
|
{% for scope_name, description in context.scope_descriptions.items %}
|
||||||
<li>{{ scope }}</li>
|
<li id="scope-{{ scope_name }}">{{ description }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{{ hidden_inputs }}
|
{{ hidden_inputs }}
|
||||||
|
|
|
@ -22,14 +22,14 @@ class UserInfoView(View):
|
||||||
"""Create a dictionary with all the requested claims about the End-User.
|
"""Create a dictionary with all the requested claims about the End-User.
|
||||||
See: http://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse"""
|
See: http://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse"""
|
||||||
|
|
||||||
def get_scope_descriptions(self, scopes: List[str]) -> List[str]:
|
def get_scope_descriptions(self, scopes: List[str]) -> Dict[str, str]:
|
||||||
"""Get a list of all Scopes's descriptions"""
|
"""Get a list of all Scopes's descriptions"""
|
||||||
scope_descriptions = []
|
scope_descriptions = {}
|
||||||
for scope in ScopeMapping.objects.filter(scope_name__in=scopes).order_by(
|
for scope in ScopeMapping.objects.filter(scope_name__in=scopes).order_by(
|
||||||
"scope_name"
|
"scope_name"
|
||||||
):
|
):
|
||||||
if scope.description != "":
|
if scope.description != "":
|
||||||
scope_descriptions.append(scope.description)
|
scope_descriptions[scope.scope_name] = scope.description
|
||||||
# GitHub Compatibility Scopes are handeled differently, since they required custom paths
|
# GitHub Compatibility Scopes are handeled differently, since they required custom paths
|
||||||
# Hence they don't exist as Scope objects
|
# Hence they don't exist as Scope objects
|
||||||
github_scope_map = {
|
github_scope_map = {
|
||||||
|
@ -44,7 +44,7 @@ class UserInfoView(View):
|
||||||
}
|
}
|
||||||
for scope in scopes:
|
for scope in scopes:
|
||||||
if scope in github_scope_map:
|
if scope in github_scope_map:
|
||||||
scope_descriptions.append(github_scope_map[scope])
|
scope_descriptions[scope] = github_scope_map[scope]
|
||||||
return scope_descriptions
|
return scope_descriptions
|
||||||
|
|
||||||
def get_claims(self, token: RefreshToken) -> Dict[str, Any]:
|
def get_claims(self, token: RefreshToken) -> Dict[str, Any]:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="pf-c-form__group">
|
<div class="pf-c-form__group">
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans with name=context.application.name %}
|
{% blocktrans with name=context.application.name %}
|
||||||
You're about to sign into {{ name }}.
|
You're about to sign into <strong id="application-name">{{ name }}</strong>.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
{{ hidden_inputs }}
|
{{ hidden_inputs }}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
{% if application_pre %}
|
{% if application_pre %}
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans with app_name=application_pre.name %}
|
{% blocktrans with app_name=application_pre.name %}
|
||||||
Login to continue to <strong>{{ app_name }}</strong>.
|
Login to continue to <strong id="application-name">{{ app_name }}</strong>.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -36,9 +36,7 @@ class OTPTimeStageView(FormView, StageView):
|
||||||
qr_code = QRCode(image_factory=SvgFillImage)
|
qr_code = QRCode(image_factory=SvgFillImage)
|
||||||
qr_code.add_data(device.config_url)
|
qr_code.add_data(device.config_url)
|
||||||
svg_image = tostring(qr_code.make_image().get_image())
|
svg_image = tostring(qr_code.make_image().get_image())
|
||||||
sr_wrapper = (
|
sr_wrapper = f'<div id="qr" data-otpuri="{device.config_url}">{force_str(svg_image)}</div>'
|
||||||
f'<div aria-label="{device.config_url}">{force_str(svg_image)}</div>'
|
|
||||||
)
|
|
||||||
return sr_wrapper
|
return sr_wrapper
|
||||||
|
|
||||||
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
|
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
|
||||||
|
|
Reference in New Issue