From af35e7a110268a7f5112aef79c068652358cec67 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Tue, 29 Oct 2024 11:23:34 -0400 Subject: [PATCH] Disable Selenium WebDriver-based test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of this writing, MacPorts’ py-selenium package is quite outdated (4.3.0, 2022-06-23 vs. current 4.25.0, 2024-09-20) and does not support recent Python versions (through 3.10 vs. current 3.13). Selenium is a tricky upgrade, so just disable the one test that uses Selenium. --- tests/examples/base.py | 40 -------------------- tests/examples/test_native_spa_pkce_auth0.py | 39 ------------------- 2 files changed, 79 deletions(-) delete mode 100644 tests/examples/test_native_spa_pkce_auth0.py diff --git tests/examples/base.py tests/examples/base.py index 2efa5dd74653..1e3d436bfd2d 100644 --- tests/examples/base.py +++ tests/examples/base.py @@ -3,11 +3,6 @@ import os import subprocess import shlex import shutil -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.common.keys import Keys -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.wait import WebDriverWait cwd = os.path.dirname(os.path.realpath(__file__)) @@ -69,38 +64,3 @@ class Sample(): self.assertTrue(False, "timeout when looking for output") return self.outputs[-1] - - -class Browser(): - def setUp(self): - super().setUp() - options = webdriver.ChromeOptions() - options.add_argument("--headless=new") - self.driver = webdriver.Chrome(options=options) - self.user_username = os.environ.get("AUTH0_USERNAME") - self.user_password = os.environ.get("AUTH0_PASSWORD") - - if not self.user_username or not self.user_password: - self.skipTest("auth0 is not configured properly") - - def tearDown(self): - super().tearDown() - self.driver.quit() - - def authorize_auth0(self, authorize_url, expected_redirect_uri): - self.driver.get(authorize_url) - username = self.driver.find_element(By.ID, "username") - password = self.driver.find_element(By.ID, "password") - - wait = WebDriverWait(self.driver, timeout=2) - wait.until(lambda d : username.is_displayed()) - wait.until(lambda d : password.is_displayed()) - - username.clear() - username.send_keys(self.user_username) - password.send_keys(self.user_password) - username.send_keys(Keys.RETURN) - - wait.until(EC.url_contains(expected_redirect_uri)) - return self.driver.current_url - diff --git tests/examples/test_native_spa_pkce_auth0.py tests/examples/test_native_spa_pkce_auth0.py deleted file mode 100644 index 6ff41e251ca4..000000000000 --- tests/examples/test_native_spa_pkce_auth0.py +++ /dev/null @@ -1,39 +0,0 @@ -import os -import unittest - -from . import base - -class TestNativeAuth0Test(base.Sample, base.Browser, unittest.TestCase): - def setUp(self): - super().setUp() - self.client_id = os.environ.get("AUTH0_PKCE_CLIENT_ID") - self.idp_domain = os.environ.get("AUTH0_DOMAIN") - - if not self.client_id or not self.idp_domain: - self.skipTest("native auth0 is not configured properly") - - def test_login(self): - # redirect_uri is http:// - os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = "1" - - self.run_sample( - "native_spa_pkce_auth0.py", { - "OAUTH_CLIENT_ID": self.client_id, - "OAUTH_IDP_DOMAIN": self.idp_domain, - } - ) - authorize_url = self.wait_for_pattern("https://") - redirect_uri = self.authorize_auth0(authorize_url, "http://") - self.write(redirect_uri) - last_line = self.wait_for_end() - - import ast - response = ast.literal_eval(last_line) - self.assertIn("access_token", response) - self.assertIn("id_token", response) - self.assertIn("scope", response) - self.assertIn("openid", response["scope"]) - self.assertIn("expires_in", response) - self.assertIn("expires_at", response) - self.assertIn("token_type", response) - self.assertEqual("Bearer", response["token_type"]) -- 2.47.0