mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-06 02:01:37 -07:00
Refactor: Simplify login redirection logic and clean up UI test code
This commit is contained in:
@@ -83,7 +83,7 @@ if ($nax_WebProtection == 'true') {
|
|||||||
$isLoggedIn = isset($_SESSION['login']) && $_SESSION['login'] == 1;
|
$isLoggedIn = isset($_SESSION['login']) && $_SESSION['login'] == 1;
|
||||||
|
|
||||||
// Determine if the user should be redirected
|
// Determine if the user should be redirected
|
||||||
if ($isLoggedIn || $isLogonPage || (isset($_COOKIE[COOKIE_SAVE_LOGIN_NAME]) && $nax_Password === $_COOKIE[COOKIE_SAVE_LOGIN_NAME])) {
|
if ($isLoggedIn || $isLogonPage) {
|
||||||
// Logged in or stay on this page if we are on the index.php already
|
// Logged in or stay on this page if we are on the index.php already
|
||||||
} else {
|
} else {
|
||||||
// We need to redirect
|
// We need to redirect
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ import os
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
|
||||||
|
|
||||||
# Add test directory to path
|
# Add test directory to path
|
||||||
sys.path.insert(0, os.path.dirname(__file__))
|
sys.path.insert(0, os.path.dirname(__file__))
|
||||||
|
|
||||||
from .test_helpers import BASE_URL, wait_for_page_load, wait_for_element_by_css # noqa: E402
|
from .test_helpers import BASE_URL, wait_for_page_load # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
def get_login_password():
|
def get_login_password():
|
||||||
@@ -32,7 +30,6 @@ def get_login_password():
|
|||||||
# SHA256 hash of "password" - the default test password (from index.php)
|
# SHA256 hash of "password" - the default test password (from index.php)
|
||||||
DEFAULT_PASSWORD_HASH = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
DEFAULT_PASSWORD_HASH = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
||||||
|
|
||||||
|
|
||||||
# Try common config file locations
|
# Try common config file locations
|
||||||
config_paths = [
|
config_paths = [
|
||||||
"/data/config/app.conf",
|
"/data/config/app.conf",
|
||||||
@@ -56,7 +53,7 @@ def get_login_password():
|
|||||||
|
|
||||||
# If it's the default, use the default password
|
# If it's the default, use the default password
|
||||||
if value == DEFAULT_PASSWORD_HASH:
|
if value == DEFAULT_PASSWORD_HASH:
|
||||||
print(f" Using default password: '123456'")
|
print(" Using default password: '123456'")
|
||||||
return "123456"
|
return "123456"
|
||||||
# If it's plaintext and looks reasonable
|
# If it's plaintext and looks reasonable
|
||||||
elif len(value) < 100 and not value.startswith('{') and value.isalnum():
|
elif len(value) < 100 and not value.startswith('{') and value.isalnum():
|
||||||
@@ -69,7 +66,7 @@ def get_login_password():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# If we couldn't determine the password from config, try default password
|
# If we couldn't determine the password from config, try default password
|
||||||
print(f"ℹ Password not determinable from config, trying default passwords...")
|
print("ℹ Password not determinable from config, trying default passwords...")
|
||||||
|
|
||||||
# For now, return first test password to try
|
# For now, return first test password to try
|
||||||
# Tests will skip if login fails
|
# Tests will skip if login fails
|
||||||
@@ -203,11 +200,6 @@ def test_login_with_deep_link_to_network_page(driver):
|
|||||||
assert '#settings-panel' in current_url, f"Expected #settings-panel hash in URL, got {current_url}"
|
assert '#settings-panel' in current_url, f"Expected #settings-panel hash in URL, got {current_url}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_login_without_next_parameter(driver):
|
def test_login_without_next_parameter(driver):
|
||||||
"""Test: Login without ?next parameter defaults to devices.php"""
|
"""Test: Login without ?next parameter defaults to devices.php"""
|
||||||
import pytest
|
import pytest
|
||||||
|
|||||||
Reference in New Issue
Block a user