diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-06-21 12:06:53 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-06-21 12:06:53 +0300 |
| commit | 7edf66a0b06a9764084ef426e53eaa28d7bd4ade (patch) | |
| tree | 73ab3c28aba500bf74870c9b38e019ac3efde6b9 /tests | |
| parent | cae23c5e14a0ed4d80e9edde351cb4066e3e350c (diff) | |
| download | the-epube-7edf66a0b06a9764084ef426e53eaa28d7bd4ade.tar.gz the-epube-7edf66a0b06a9764084ef426e53eaa28d7bd4ade.tar.xz | |
fix validate_session() not being used in AuthRequired check
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/RouterTest.php | 1 | ||||
| -rw-r--r-- | tests/bootstrap.php | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 1c2197c..58887c3 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -132,6 +132,7 @@ final class RouterTest extends TestCase }; $this->router->addRoute('protected', $handler); $_SESSION['owner'] = 'testuser'; + $_SESSION['pass_hash'] = 'dummy'; $response = $this->router->dispatchResponse('protected'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8cae8e1..a484982 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,3 +5,11 @@ putenv("IS_TESTING=true"); require_once "common.php"; + + // Stub validate_session() for unit tests (no DB needed). + // Integration tests load sessions.php which defines the real function. + if (!function_exists('validate_session')) { + function validate_session() : bool { + return !empty($_SESSION["owner"]) && !empty($_SESSION["pass_hash"]); + } + } |
