2 Commits

Author SHA1 Message Date
Sebastian 9bcc117b41 chore(deps): update dependency jsdom to v30
Build Test / test (pull_request) Successful in 42s
JS Unit Tests / test (pull_request) Successful in 28s
PHP Integration Tests / Integration Tests (pull_request) Failing after 1m15s
PHP Unit Tests / test (pull_request) Successful in 1m52s
2026-07-28 03:04:31 +00:00
Sebastian 3556be7c85 refactor: migrate to scoped execution contexts
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-27 00:50:43 -04:00
5 changed files with 79 additions and 85 deletions
Generated
+7 -7
View File
@@ -589,16 +589,16 @@
},
{
"name": "phpunit/phpunit",
"version": "12.5.32",
"version": "12.5.31",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f"
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c02591dd7840ed124a98d7770753329ad28e9f8f",
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0608d157a284f15cc73b99a3327eff06b66a176d",
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d",
"shasum": ""
},
"require": {
@@ -667,7 +667,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.32"
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.31"
},
"funding": [
{
@@ -675,7 +675,7 @@
"type": "other"
}
],
"time": "2026-07-25T06:54:13+00:00"
"time": "2026-07-06T14:54:16+00:00"
},
{
"name": "sebastian/cli-parser",
@@ -1698,5 +1698,5 @@
"php": ">=8.3"
},
"platform-dev": {},
"plugin-api-version": "2.9.0"
"plugin-api-version": "2.6.0"
}
+9 -9
View File
@@ -4,8 +4,8 @@ namespace KTXM\AuthenticationProviderPassword\Controllers;
use KTXC\Http\Response\JsonResponse;
use KTXC\Service\UserAccountsService;
use KTXC\SessionIdentity;
use KTXC\SessionTenant;
use KTXC\Context\IdentityContextInterface;
use KTXC\Context\TenantContextInterface;
use KTXF\Controller\ControllerAbstract;
use KTXF\Routing\Attributes\AuthenticatedRoute;
use KTXF\Security\Crypto;
@@ -15,8 +15,8 @@ use KTXM\AuthenticationProviderPassword\Stores\CredentialStore;
class PasswordController extends ControllerAbstract
{
public function __construct(
private readonly SessionIdentity $sessionIdentity,
private readonly SessionTenant $sessionTenant,
private readonly IdentityContextInterface $identityContext,
private readonly TenantContextInterface $tenantContext,
private readonly CredentialStore $credentialStore,
private readonly Provider $provider,
private readonly Crypto $crypto,
@@ -27,8 +27,8 @@ class PasswordController extends ControllerAbstract
#[AuthenticatedRoute('/password/update', name: 'password.update', methods: ['POST'])]
public function update(string $current_password, string $new_password): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
$identifier = $this->sessionIdentity->mailAddress();
$tenantId = $this->tenantContext->identifier();
$identifier = $this->identityContext->mailAddress();
if ($tenantId === null || $identifier === null) {
return new JsonResponse(['error' => 'Invalid session state'], 400);
@@ -56,7 +56,7 @@ class PasswordController extends ControllerAbstract
#[AuthenticatedRoute('/status', name: 'password.admin.status', methods: ['POST'], permissions: ['authentication_provider_password.admin.view', 'authentication_provider_password.admin.manage'])]
public function getStatus(string $uid): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
$tenantId = $this->tenantContext->identifier();
if ($tenantId === null) {
return new JsonResponse(['error' => 'Invalid session state'], 400);
@@ -82,7 +82,7 @@ class PasswordController extends ControllerAbstract
#[AuthenticatedRoute('/reset', name: 'password.admin.reset', methods: ['POST'], permissions: ['authentication_provider_password.admin.manage'])]
public function adminReset(string $uid, string $password): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
$tenantId = $this->tenantContext->identifier();
if ($tenantId === null) {
return new JsonResponse(['error' => 'Invalid session state'], 400);
@@ -113,7 +113,7 @@ class PasswordController extends ControllerAbstract
#[AuthenticatedRoute('/remove', name: 'password.admin.remove', methods: ['POST'], permissions: ['authentication_provider_password.admin.manage'])]
public function adminRemove(string $uid): JsonResponse
{
$tenantId = $this->sessionTenant->identifier();
$tenantId = $this->tenantContext->identifier();
if ($tenantId === null) {
return new JsonResponse(['error' => 'Invalid session state'], 400);
+47 -50
View File
@@ -15,7 +15,7 @@
"@vitejs/plugin-vue": "^6.0.0",
"@vitest/coverage-v8": "^4.1.6",
"@vue/test-utils": "^2.4.10",
"jsdom": "^29.1.1",
"jsdom": "^30.0.0",
"typescript": "~6.0.0",
"vite": "^8.0.0",
"vitest": "^4.1.6",
@@ -23,56 +23,38 @@
}
},
"node_modules/@asamuzakjp/css-color": {
"version": "5.1.11",
"resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-5.1.11.tgz",
"integrity": "sha512-KVw6qIiCTUQhByfTd78h2yD1/00waTmm9uy/R7Ck/ctUyAPj+AEDLkQIdJW0T8+qGgj3j5bpNKK7Q3G+LedJWg==",
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-6.0.5.tgz",
"integrity": "sha512-mbhpPMmnw/kwW19aRNmSUl1QzLbdGo1SCuE49BT98MNwqF6zaHb3o2owssFc/PEO/4t2UjqtCNwocuDtJornzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@asamuzakjp/generational-cache": "^1.0.1",
"@csstools/css-calc": "^3.2.0",
"@csstools/css-color-parser": "^4.1.0",
"@csstools/css-calc": "^3.2.1",
"@csstools/css-color-parser": "^4.1.9",
"@csstools/css-parser-algorithms": "^4.0.0",
"@csstools/css-tokenizer": "^4.0.0"
"@csstools/css-tokenizer": "^4.0.0",
"lru-cache": "^11.5.2"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
"node": "^22.13.0 || >=24.0.0"
}
},
"node_modules/@asamuzakjp/dom-selector": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-7.1.1.tgz",
"integrity": "sha512-67RZDnYRc8H/8MLDgQCDE//zoqVFwajkepHZgmXrbwybzXOEwOWGPYGmALYl9J2DOLfFPPs6kKCqmbzV895hTQ==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-8.3.0.tgz",
"integrity": "sha512-UJLfKXBhrc8i1vH2eJXuYQMwlsLKWFw3O+CPqXSuVEiikeAim3UgrfWX0k4tA/X8cRFM8iZ7OaqBokFGbYusdg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@asamuzakjp/generational-cache": "^1.0.1",
"@asamuzakjp/nwsapi": "^2.3.9",
"bidi-js": "^1.0.3",
"css-tree": "^3.2.1",
"is-potential-custom-element-name": "^1.0.1"
"is-potential-custom-element-name": "^1.0.1",
"lru-cache": "^11.5.2"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
"node": "^22.13.0 || >=24.0.0"
}
},
"node_modules/@asamuzakjp/generational-cache": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@asamuzakjp/generational-cache/-/generational-cache-1.0.1.tgz",
"integrity": "sha512-wajfB8KqzMCN2KGNFdLkReeHncd0AslUSrvHVvvYWuU8ghncRJoA50kT3zP9MVL0+9g4/67H+cdvBskj9THPzg==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
}
},
"node_modules/@asamuzakjp/nwsapi": {
"version": "2.3.9",
"resolved": "https://registry.npmjs.org/@asamuzakjp/nwsapi/-/nwsapi-2.3.9.tgz",
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
"dev": true,
"license": "MIT"
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
@@ -1587,39 +1569,39 @@
"license": "MIT"
},
"node_modules/jsdom": {
"version": "29.1.1",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-29.1.1.tgz",
"integrity": "sha512-ECi4Fi2f7BdJtUKTflYRTiaMxIB0O6zfR1fX0GXpUrf6flp8QIYn1UT20YQqdSOfk2dfkCwS8LAFoJDEppNK5Q==",
"version": "30.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.0.0.tgz",
"integrity": "sha512-JQHfRGmmKmaZoUAvIgff5jjG/0SzTQlGz8c7t72KzBzo8ZULEjAjnYE0sNwBOUA4QtWwYE2xoYitg8NFsmiYxA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@asamuzakjp/css-color": "^5.1.11",
"@asamuzakjp/dom-selector": "^7.1.1",
"@asamuzakjp/css-color": "^6.0.5",
"@asamuzakjp/dom-selector": "^8.2.5",
"@bramus/specificity": "^2.4.2",
"@csstools/css-syntax-patches-for-csstree": "^1.1.3",
"@exodus/bytes": "^1.15.0",
"@csstools/css-syntax-patches-for-csstree": "^1.1.6",
"@exodus/bytes": "^1.15.1",
"css-tree": "^3.2.1",
"data-urls": "^7.0.0",
"decimal.js": "^10.6.0",
"html-encoding-sniffer": "^6.0.0",
"is-potential-custom-element-name": "^1.0.1",
"lru-cache": "^11.3.5",
"lru-cache": "^11.5.2",
"parse5": "^8.0.1",
"saxes": "^6.0.0",
"symbol-tree": "^3.2.4",
"tough-cookie": "^6.0.1",
"undici": "^7.25.0",
"tough-cookie": "^6.0.2",
"undici": "^8.7.0",
"w3c-xmlserializer": "^5.0.0",
"webidl-conversions": "^8.0.1",
"whatwg-mimetype": "^5.0.0",
"whatwg-url": "^16.0.1",
"whatwg-url": "^17.1.0",
"xml-name-validator": "^5.0.0"
},
"engines": {
"node": "^20.19.0 || ^22.13.0 || >=24.0.0"
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
},
"peerDependencies": {
"canvas": "^3.0.0"
"canvas": "^3.2.3"
},
"peerDependenciesMeta": {
"canvas": {
@@ -1627,6 +1609,21 @@
}
}
},
"node_modules/jsdom/node_modules/whatwg-url": {
"version": "17.1.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.1.0.tgz",
"integrity": "sha512-3GeworPmc2ZfEEHP7lEbUfBX/L75wdEsi0rLNhXcXxnoN5jyq0SL5gCy06SGW2cyTIZdTvWIDQNQoza++vKeaw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@exodus/bytes": "^1.15.1",
"tr46": "^6.0.0",
"webidl-conversions": "^8.0.1"
},
"engines": {
"node": "^22.14.0 || >=24.0.0"
}
},
"node_modules/lightningcss": {
"version": "1.32.0",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",
@@ -2541,13 +2538,13 @@
}
},
"node_modules/undici": {
"version": "7.28.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.28.0.tgz",
"integrity": "sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==",
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-8.9.0.tgz",
"integrity": "sha512-aWZpUj7XoGonMClx4gdDRfgBjqeA+F473aDmROQQbM9n6PRfK/u1q/a0X4wMTgcHfT8H6fpbt98PFuDUwFg2YA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=20.18.1"
"node": ">=22.19.0"
}
},
"node_modules/vite": {
+1 -1
View File
@@ -27,7 +27,7 @@
"vue-tsc": "^3.0.0",
"@vitest/coverage-v8": "^4.1.6",
"@vue/test-utils": "^2.4.10",
"jsdom": "^29.1.1",
"jsdom": "^30.0.0",
"vitest": "^4.1.6"
}
}
+15 -18
View File
@@ -6,7 +6,7 @@ namespace KTXT\AuthenticationProviderPassword\Tests\Integration;
use KTXC\Http\Request\Request;
use KTXC\Http\Response\Response;
use KTXC\Server;
use KTXC\Application;
use KTXC\Stores\UserRolesStore;
use PHPUnit\Framework\TestCase;
@@ -19,11 +19,11 @@ use PHPUnit\Framework\TestCase;
* through the real HTTP kernel (routing, tenant resolution, auth middleware,
* controller), not by calling controllers directly.
*
* A fresh Server (and DI container) is built for every request() call,
* A fresh Application (and DI container) is built for every request() call,
* mirroring the one-process-per-request model this app is actually
* deployed under. Session identity is a container-lifetime singleton that
* AuthenticationMiddleware only ever sets, never clears, so reusing one
* Server across requests would leak an authenticated identity from one
* Application across requests would leak an authenticated identity from one
* "request" into the next — a problem that can't occur in production,
* where each request gets its own process, but very much can here.
*
@@ -37,7 +37,7 @@ abstract class IntegrationTestCase extends TestCase
public static function setUpBeforeClass(): void
{
if (static::buildServer()->environment() === 'prod') {
if (static::buildApplication()->environment() === 'prod') {
self::fail('Refusing to run integration tests against a server configured for the "prod" environment.');
}
@@ -58,9 +58,9 @@ abstract class IntegrationTestCase extends TestCase
}
}
protected static function buildServer(): Server
protected static function buildApplication(): Application
{
return new Server(SERVER_ROOT);
return Application::create(SERVER_ROOT);
}
// =========================================================================
@@ -103,17 +103,16 @@ abstract class IntegrationTestCase extends TestCase
*/
protected static function createRoleWithPermissions(array $permissions, string $label = 'Test Role'): string
{
$server = static::buildServer();
$application = static::buildApplication();
try {
$server->kernel()->boot();
$store = $server->container()->get(UserRolesStore::class);
$application->kernel()->boot();
$store = $application->container()->get(UserRolesStore::class);
$role = $store->createRole(static::$tenantIdentifier, [
'label' => $label,
'permissions' => $permissions,
]);
} finally {
restore_error_handler();
restore_exception_handler();
$application->shutdown();
}
return $role['rid'];
@@ -174,15 +173,13 @@ abstract class IntegrationTestCase extends TestCase
$uri = 'http://' . static::$tenantDomain . $path;
$request = Request::create($uri, $method, [], [], [], $server, $content);
// Kernel::boot() registers a global error/exception handler per
// instance and never removes it (fine under one-process-per-request
// in production; here it would otherwise stack a handler per test).
// Pop back to whatever was in place before this request.
// A fresh application mirrors production while shutdown restores its
// process-level error handler after the in-process request.
$application = static::buildApplication();
try {
$response = static::buildServer()->handle($request);
$response = $application->handleHttp($request);
} finally {
restore_error_handler();
restore_exception_handler();
$application->shutdown();
}
$body = $response->getContent();