From b9ed514ef2b52fc52b97a3422b5916c488032f3b Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Tue, 17 May 2022 09:54:09 +0200 Subject: [PATCH 01/22] Adding a functional test which covers all functions --- Configuration/Testing/Settings.yaml | 2 + .../Fixtures/Controller/ExampleController.php | 43 ++++++++ .../SessionLockRequestComponentTest.php | 100 ++++++++++++++++++ composer.json | 3 + 4 files changed, 148 insertions(+) create mode 100644 Tests/Functional/Fixtures/Controller/ExampleController.php create mode 100644 Tests/Functional/SessionLockRequestComponentTest.php diff --git a/Configuration/Testing/Settings.yaml b/Configuration/Testing/Settings.yaml index 07b1b05..31d150d 100644 --- a/Configuration/Testing/Settings.yaml +++ b/Configuration/Testing/Settings.yaml @@ -1,3 +1,5 @@ DigiComp: FlowSessionLock: lockStoreConnection: "flock://%FLOW_PATH_DATA%Temporary/Testing/SessionLocks/" + readOnlyExpressions: + TestUnprotected: "method(DigiComp\\FlowSessionLock\\Tests\\Functional\\Fixtures\\Controller\\ExampleController->unprotectedByConfigurationAction())" diff --git a/Tests/Functional/Fixtures/Controller/ExampleController.php b/Tests/Functional/Fixtures/Controller/ExampleController.php new file mode 100644 index 0000000..a5ecab9 --- /dev/null +++ b/Tests/Functional/Fixtures/Controller/ExampleController.php @@ -0,0 +1,43 @@ +serverRequestFactory = $this->objectManager->get(ServerRequestFactoryInterface::class); + $route = new Route(); + $route->setName('Functional Test - SessionRequestComponent::Restricted'); + $route->setUriPattern('test/sessionlock/{@action}'); + $route->setDefaults([ + '@package' => 'DigiComp.FlowSessionLock', + '@subpackage' => 'Tests\Functional\Fixtures', + '@controller' => 'Example', + '@action' => 'protected', + '@format' => 'html', + ]); + $route->setAppendExceedingArguments(true); + $this->router->addRoute($route); + } + + public function expectedDuration(): array + { + $parallelChecker = function ($allRequests, $oneRequest) { + self::assertGreaterThan(ExampleController::CONTROLLER_TIME, $oneRequest * 1000); + self::assertLessThan(ExampleController::CONTROLLER_TIME * 4, $allRequests * 1000); + }; + return [ + [ + 'http://localhost/test/sessionlock/protected', + function ($allRequests, $oneRequest) { + self::assertGreaterThan(ExampleController::CONTROLLER_TIME, $oneRequest * 1000); + self::assertGreaterThan(ExampleController::CONTROLLER_TIME * 4, $allRequests * 1000); + } + ], + [ + 'http://localhost/test/sessionlock/unprotectedbyannotation', + $parallelChecker + ], + [ + 'http://localhost/test/sessionlock/unprotectedbyconfiguration', + $parallelChecker + ] + ]; + } + + /** + * @dataProvider expectedDuration + * @test + */ + public function itDoesNotAllowToEnterMoreThanOneWithTheSameSession(string $url, \Closure $checker): void + { + $request = $this->serverRequestFactory + ->createServerRequest('GET', new Uri($url)); + $start = microtime(true); + $response = $this->browser->sendRequest($request); + $neededForOne = microtime(true) - $start; + + $sessionCookies = array_map(static function ($cookie) { + return Cookie::createFromRawSetCookieHeader($cookie); + }, $response->getHeader('Set-Cookie')); + self::assertNotEmpty($sessionCookies); + + $cookies = array_reduce($sessionCookies, static function ($out, $cookie) { + $out[$cookie->getName()] = $cookie->getValue(); + return $out; + }, []); + $nextRequest = $this->serverRequestFactory + ->createServerRequest('GET', new Uri($url)) + ->withCookieParams($cookies); + $childs = []; + $start = microtime(true); + for ($i = 0; $i < 4; $i++) { + $child = \pcntl_fork(); + if ($child === 0) { + $this->browser->sendRequest($nextRequest); + exit(); + } + $childs[] = $child; + } + foreach ($childs as $child) { + \pcntl_waitpid($child, $status); + } + $neededForAll = microtime(true) - $start; + + $checker($neededForAll, $neededForOne); + } +} diff --git a/composer.json b/composer.json index 567cb4a..e707dfc 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,9 @@ "php": ">=7.4", "symfony/lock": "^5.2.0" }, + "require-dev": { + "ext-pcntl": "*" + }, "autoload": { "psr-4": { "DigiComp\\FlowSessionLock\\": "Classes/" From f7914f7a4be561b0e2417dc7fc42794875ee2eb3 Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 02/22] TASK: Apply migration Neos.SwiftMailer-20161130105617 Adjusts code to package renaming from "TYPO3.SwiftMailer" to "Neos.SwiftMailer". Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e707dfc..a1a5273 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,10 @@ }, "branch-alias": { "dev-develop": "2.0.x-dev" - } + }, + "applied-flow-migrations": [ + "Neos.SwiftMailer-20161130105617" + ] }, "authors": [ { @@ -37,4 +40,4 @@ "Neos", "Flow" ] -} +} \ No newline at end of file From abfb8332b333dea4a1188460aa30fd718aa28576 Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 03/22] TASK: Apply migration Neos.Flow-20180415105700 Add scalar type hint to CacheAwareInterface implementations. Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a1a5273..09ba2e7 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "dev-develop": "2.0.x-dev" }, "applied-flow-migrations": [ - "Neos.SwiftMailer-20161130105617" + "Neos.SwiftMailer-20161130105617", + "Neos.Flow-20180415105700" ] }, "authors": [ From d3714249e58beb56b46c32e4d2aac54b7f424b9b Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 04/22] TASK: Apply migration Neos.Flow-20190425144900 Adjusts code to FlashMessageContainer renaming from "\Neos\Flow\Mvc" to "\Neos\Flow\Mvc\FlashMessage". Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 09ba2e7..953f546 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ }, "applied-flow-migrations": [ "Neos.SwiftMailer-20161130105617", - "Neos.Flow-20180415105700" + "Neos.Flow-20180415105700", + "Neos.Flow-20190425144900" ] }, "authors": [ From 5ed22d20f0cef9efa97418ad36acd185e73ada85 Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 05/22] TASK: Apply migration Neos.Flow-20190515215000 Adjust "Settings.yaml" to new PSR-3 logging settings (see https://github.com/neos/flow-development-collection/pull/1574) Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 953f546..506701f 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "applied-flow-migrations": [ "Neos.SwiftMailer-20161130105617", "Neos.Flow-20180415105700", - "Neos.Flow-20190425144900" + "Neos.Flow-20190425144900", + "Neos.Flow-20190515215000" ] }, "authors": [ From 730632081490e30cc3f91c65ebaa1c08cf2dff1d Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 06/22] TASK: Apply migration Neos.Flow-20200813181400 Adjust "Settings.yaml" to new naming of settings (see https://github.com/neos/flow-development-collection/pull/2051) Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 506701f..b40b37c 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "Neos.SwiftMailer-20161130105617", "Neos.Flow-20180415105700", "Neos.Flow-20190425144900", - "Neos.Flow-20190515215000" + "Neos.Flow-20190515215000", + "Neos.Flow-20200813181400" ] }, "authors": [ From 4dfb3b85682a93b725b9ca773a13f081cca0770b Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 07/22] TASK: Apply migration Neos.Flow-20201003165200 Make default ValueObjects embedded=false Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b40b37c..80c69cf 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "Neos.Flow-20180415105700", "Neos.Flow-20190425144900", "Neos.Flow-20190515215000", - "Neos.Flow-20200813181400" + "Neos.Flow-20200813181400", + "Neos.Flow-20201003165200" ] }, "authors": [ From 5d8e93084bdf7141ab6da2066ce4b0ec4aedf5bf Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 08/22] TASK: Apply migration Neos.Flow-20201109224100 Adjust DB migrations to Doctrine Migrations 3.0 Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 80c69cf..19e1391 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "Neos.Flow-20190425144900", "Neos.Flow-20190515215000", "Neos.Flow-20200813181400", - "Neos.Flow-20201003165200" + "Neos.Flow-20201003165200", + "Neos.Flow-20201109224100" ] }, "authors": [ From e58a157037274a39b0d5c3b015e560ef9c471a5c Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 09/22] TASK: Apply migration Neos.Flow-20201205172733 This migration does not actually change any code. It just displays a warning if a PHP file still refers to the no longer existing ComponentInterface Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 19e1391..1593054 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "Neos.Flow-20190515215000", "Neos.Flow-20200813181400", "Neos.Flow-20201003165200", - "Neos.Flow-20201109224100" + "Neos.Flow-20201109224100", + "Neos.Flow-20201205172733" ] }, "authors": [ From d7dbff9fc2b8c198f0f0f0f89c2dc0d342fd59a7 Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:51:43 +0200 Subject: [PATCH 10/22] TASK: Apply migration Neos.Flow-20201207104500 Adjust code to deprecation of ComponentContext/ComponentParameters Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1593054..d775e36 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "Neos.Flow-20200813181400", "Neos.Flow-20201003165200", "Neos.Flow-20201109224100", - "Neos.Flow-20201205172733" + "Neos.Flow-20201205172733", + "Neos.Flow-20201207104500" ] }, "authors": [ From 28c6c8ef598fc42e8eaff66735d4ddea23bbbd2a Mon Sep 17 00:00:00 2001 From: Marvin Kuhl Date: Thu, 19 May 2022 11:53:26 +0200 Subject: [PATCH 11/22] [WIP] migrates SessionLockRequestComponent to new MiddlewareInterface --- Classes/Aspects/ReadOnlyAspect.php | 7 +++---- ...ent.php => SessionLockRequestMiddleware.php} | 17 ++++++++++------- Configuration/Settings.yaml | 10 ++++------ composer.json | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename Classes/Http/{SessionLockRequestComponent.php => SessionLockRequestMiddleware.php} (78%) diff --git a/Classes/Aspects/ReadOnlyAspect.php b/Classes/Aspects/ReadOnlyAspect.php index 3ece8df..3728566 100644 --- a/Classes/Aspects/ReadOnlyAspect.php +++ b/Classes/Aspects/ReadOnlyAspect.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace DigiComp\FlowSessionLock\Aspects; -use DigiComp\FlowSessionLock\Http\SessionLockRequestComponent; +use DigiComp\FlowSessionLock\Http\SessionLockRequestMiddleware; use Neos\Flow\Annotations as Flow; use Neos\Flow\Aop\JoinPointInterface; use Neos\Flow\Core\Bootstrap; @@ -52,9 +52,8 @@ class ReadOnlyAspect $this->readOnly = true; /** @var Lock|null $lock */ - $lock = $activeRequestHandler->getComponentContext()->getParameter( - SessionLockRequestComponent::class, - SessionLockRequestComponent::PARAMETER_NAME + $lock = $activeRequestHandler->getHttpRequest()->getAttribute( + SessionLockRequestMiddleware::class . '.' . SessionLockRequestMiddleware::PARAMETER_NAME ); if ($lock !== null) { $this->logger->debug('SessionLock: Release, as this is marked read only.'); diff --git a/Classes/Http/SessionLockRequestComponent.php b/Classes/Http/SessionLockRequestMiddleware.php similarity index 78% rename from Classes/Http/SessionLockRequestComponent.php rename to Classes/Http/SessionLockRequestMiddleware.php index 43109ad..a8630da 100644 --- a/Classes/Http/SessionLockRequestComponent.php +++ b/Classes/Http/SessionLockRequestMiddleware.php @@ -5,14 +5,16 @@ declare(strict_types=1); namespace DigiComp\FlowSessionLock\Http; use Neos\Flow\Annotations as Flow; -use Neos\Flow\Http\Component\ComponentContext; -use Neos\Flow\Http\Component\ComponentInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\MiddlewareInterface; +use Psr\Http\Server\RequestHandlerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Lock\Exception\LockAcquiringException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\LockFactory; -class SessionLockRequestComponent implements ComponentInterface +class SessionLockRequestMiddleware implements MiddlewareInterface { public const PARAMETER_NAME = 'sessionLock'; @@ -55,13 +57,13 @@ class SessionLockRequestComponent implements ComponentInterface /** * @inheritDoc */ - public function handle(ComponentContext $componentContext): void + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $sessionCookieName = $this->sessionSettings['name']; - $cookies = $componentContext->getHttpRequest()->getCookieParams(); + $cookies = $request->getCookieParams(); if (!isset($cookies[$sessionCookieName])) { - return; + return $handler->handle($request); } // TODO: sessionIdentifier might be wrong, probably it should probably be storage identifier @@ -69,7 +71,7 @@ class SessionLockRequestComponent implements ComponentInterface $lock = $this->lockFactory->createLockFromKey($key, $this->timeToLive, $this->autoRelease); - $componentContext->setParameter(SessionLockRequestComponent::class, static::PARAMETER_NAME, $lock); + $request = $request->withAttribute(static::class . '.' . static::PARAMETER_NAME, $lock); $this->logger->debug('SessionLock: Try to get "' . $key . '"'); $timedOut = \time() + $this->secondsToWait; @@ -83,5 +85,6 @@ class SessionLockRequestComponent implements ComponentInterface \usleep(100000); } $this->logger->debug('SessionLock: Acquired "' . $key . '"'); + return $handler->handle($request); } } diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index f283d84..08c69fc 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -9,9 +9,7 @@ DigiComp: Neos: Flow: http: - chain: - preprocess: - chain: - lockSession: - position: "before getSessionCookieFromRequest" - component: "DigiComp\\FlowSessionLock\\Http\\SessionLockRequestComponent" + middlewares: + lockSession: + position: "before session" + middleware: "DigiComp\\FlowSessionLock\\Http\\SessionLockRequestMiddleware" diff --git a/composer.json b/composer.json index d775e36..1858857 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Session locking for Neos Flow - it secures the session becoming corrupted by concurrent access to the same session by different requests", "type": "neos-package", "require": { - "neos/flow": "^6.3.0", + "neos/flow": "^7.3.0", "php": ">=7.4", "symfony/lock": "^5.2.0" }, From 0ae4ab9269444898e6aee0876dd1e783ef266fe3 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Wed, 1 Jun 2022 00:25:02 +0200 Subject: [PATCH 12/22] do not use static class name as key in proxied classes (changes after compile run to "_Original") --- Classes/Http/SessionLockRequestMiddleware.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Http/SessionLockRequestMiddleware.php b/Classes/Http/SessionLockRequestMiddleware.php index a8630da..261de86 100644 --- a/Classes/Http/SessionLockRequestMiddleware.php +++ b/Classes/Http/SessionLockRequestMiddleware.php @@ -14,6 +14,7 @@ use Symfony\Component\Lock\Exception\LockAcquiringException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\LockFactory; + class SessionLockRequestMiddleware implements MiddlewareInterface { public const PARAMETER_NAME = 'sessionLock'; @@ -71,7 +72,7 @@ class SessionLockRequestMiddleware implements MiddlewareInterface $lock = $this->lockFactory->createLockFromKey($key, $this->timeToLive, $this->autoRelease); - $request = $request->withAttribute(static::class . '.' . static::PARAMETER_NAME, $lock); + $request = $request->withAttribute(SessionLockRequestMiddleware::class . '.' . static::PARAMETER_NAME, $lock); $this->logger->debug('SessionLock: Try to get "' . $key . '"'); $timedOut = \time() + $this->secondsToWait; From 7c13ff8e71cc85efa14e7c2f107bcb725cdb5682 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Sun, 31 Jul 2022 23:51:35 +0200 Subject: [PATCH 13/22] PHPCBF fixes --- Classes/Http/SessionLockRequestMiddleware.php | 1 - .../SessionLockRequestComponentTest.php | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Classes/Http/SessionLockRequestMiddleware.php b/Classes/Http/SessionLockRequestMiddleware.php index 261de86..ecad355 100644 --- a/Classes/Http/SessionLockRequestMiddleware.php +++ b/Classes/Http/SessionLockRequestMiddleware.php @@ -14,7 +14,6 @@ use Symfony\Component\Lock\Exception\LockAcquiringException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\LockFactory; - class SessionLockRequestMiddleware implements MiddlewareInterface { public const PARAMETER_NAME = 'sessionLock'; diff --git a/Tests/Functional/SessionLockRequestComponentTest.php b/Tests/Functional/SessionLockRequestComponentTest.php index e4daff9..5203212 100644 --- a/Tests/Functional/SessionLockRequestComponentTest.php +++ b/Tests/Functional/SessionLockRequestComponentTest.php @@ -43,16 +43,16 @@ class SessionLockRequestComponentTest extends FunctionalTestCase function ($allRequests, $oneRequest) { self::assertGreaterThan(ExampleController::CONTROLLER_TIME, $oneRequest * 1000); self::assertGreaterThan(ExampleController::CONTROLLER_TIME * 4, $allRequests * 1000); - } + }, ], [ 'http://localhost/test/sessionlock/unprotectedbyannotation', - $parallelChecker + $parallelChecker, ], [ 'http://localhost/test/sessionlock/unprotectedbyconfiguration', - $parallelChecker - ] + $parallelChecker, + ], ]; } @@ -64,16 +64,16 @@ class SessionLockRequestComponentTest extends FunctionalTestCase { $request = $this->serverRequestFactory ->createServerRequest('GET', new Uri($url)); - $start = microtime(true); + $start = \microtime(true); $response = $this->browser->sendRequest($request); - $neededForOne = microtime(true) - $start; + $neededForOne = \microtime(true) - $start; - $sessionCookies = array_map(static function ($cookie) { + $sessionCookies = \array_map(static function ($cookie) { return Cookie::createFromRawSetCookieHeader($cookie); }, $response->getHeader('Set-Cookie')); self::assertNotEmpty($sessionCookies); - $cookies = array_reduce($sessionCookies, static function ($out, $cookie) { + $cookies = \array_reduce($sessionCookies, static function ($out, $cookie) { $out[$cookie->getName()] = $cookie->getValue(); return $out; }, []); @@ -81,7 +81,7 @@ class SessionLockRequestComponentTest extends FunctionalTestCase ->createServerRequest('GET', new Uri($url)) ->withCookieParams($cookies); $childs = []; - $start = microtime(true); + $start = \microtime(true); for ($i = 0; $i < 4; $i++) { $child = \pcntl_fork(); if ($child === 0) { @@ -93,7 +93,7 @@ class SessionLockRequestComponentTest extends FunctionalTestCase foreach ($childs as $child) { \pcntl_waitpid($child, $status); } - $neededForAll = microtime(true) - $start; + $neededForAll = \microtime(true) - $start; $checker($neededForAll, $neededForOne); } From 9f30b80d39b942775957a83fc93fcd495704d004 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Sun, 31 Jul 2022 23:52:38 +0200 Subject: [PATCH 14/22] Marking breaking change --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1858857..d2bbd92 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "package-key": "DigiComp.FlowSessionLock" }, "branch-alias": { - "dev-develop": "2.0.x-dev" + "dev-develop": "3.0.x-dev" }, "applied-flow-migrations": [ "Neos.SwiftMailer-20161130105617", @@ -48,4 +48,4 @@ "Neos", "Flow" ] -} \ No newline at end of file +} From 287ef82621edd678ff5d1f8cd6dbbd229a9b4b0b Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 00:17:55 +0200 Subject: [PATCH 15/22] note about broken functional tests --- Tests/Functional/SessionLockRequestComponentTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/Functional/SessionLockRequestComponentTest.php b/Tests/Functional/SessionLockRequestComponentTest.php index 5203212..3de1358 100644 --- a/Tests/Functional/SessionLockRequestComponentTest.php +++ b/Tests/Functional/SessionLockRequestComponentTest.php @@ -4,6 +4,7 @@ namespace DigiComp\FlowSessionLock\Tests\Functional; use DigiComp\FlowSessionLock\Tests\Functional\Fixtures\Controller\ExampleController; use GuzzleHttp\Psr7\Uri; +use Neos\Flow\Composer\ComposerUtility; use Neos\Flow\Http\Cookie; use Neos\Flow\Mvc\Routing\Route; use Neos\Flow\Tests\FunctionalTestCase; @@ -62,6 +63,9 @@ class SessionLockRequestComponentTest extends FunctionalTestCase */ public function itDoesNotAllowToEnterMoreThanOneWithTheSameSession(string $url, \Closure $checker): void { + // Functional tests are currently broken, until a version containing + // https://github.com/neos/flow-development-collection/commit/bebfc4e6566bc4ba2ba28330344105adb2d6ada0 + // gets released $request = $this->serverRequestFactory ->createServerRequest('GET', new Uri($url)); $start = \microtime(true); From aa150cea9fbe2f3b5ac22a3005d915bb9e539e6d Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 00:18:22 +0200 Subject: [PATCH 16/22] Adding code-style build pipeline --- .woodpecker/code-style.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .woodpecker/code-style.yml diff --git a/.woodpecker/code-style.yml b/.woodpecker/code-style.yml new file mode 100644 index 0000000..e9d28f7 --- /dev/null +++ b/.woodpecker/code-style.yml @@ -0,0 +1,7 @@ +pipeline: + code-style: + image: composer + commands: + - composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer + - composer global require digicomp/php-codesniffer:@dev + - composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Tests/ From e7c8492b74440afb57409477f7872ed2db890fc4 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 00:29:51 +0200 Subject: [PATCH 17/22] Updating branch aliases --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 811e3c2..758ea6f 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "package-key": "DigiComp.FlowSessionLock" }, "branch-alias": { - "dev-develop": "1.0.x-dev" + "dev-develop": "3.0.x-dev", + "dev-version/2.x-dev": "2.1.x-dev" } } } From 9f7dab75139f56a0a572a315cd87906181645503 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 00:37:15 +0200 Subject: [PATCH 18/22] Allow phpcodesniffer composer installer scripts in CI --- .woodpecker/code-style.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker/code-style.yml b/.woodpecker/code-style.yml index e9d28f7..d36b348 100644 --- a/.woodpecker/code-style.yml +++ b/.woodpecker/code-style.yml @@ -3,5 +3,6 @@ pipeline: image: composer commands: - composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer + - composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true - composer global require digicomp/php-codesniffer:@dev - composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Tests/ From 84e52eaa6820fffbeff7b5e7fd501cf5ce8554e8 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 01:02:58 +0200 Subject: [PATCH 19/22] Allow phpcodesniffer composer installer scripts in CI --- .woodpecker/code-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker/code-style.yml b/.woodpecker/code-style.yml index d36b348..bfd94b0 100644 --- a/.woodpecker/code-style.yml +++ b/.woodpecker/code-style.yml @@ -3,6 +3,6 @@ pipeline: image: composer commands: - composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer - - composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + - composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true - composer global require digicomp/php-codesniffer:@dev - composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Tests/ From 1c3b713c2dc69ceb270497e77a16fc3af73f8738 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 1 Aug 2022 01:05:38 +0200 Subject: [PATCH 20/22] Removing obsolete class, slipped in during experimenting with automatic skipping --- Tests/Functional/SessionLockRequestComponentTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Functional/SessionLockRequestComponentTest.php b/Tests/Functional/SessionLockRequestComponentTest.php index 3de1358..c03d781 100644 --- a/Tests/Functional/SessionLockRequestComponentTest.php +++ b/Tests/Functional/SessionLockRequestComponentTest.php @@ -4,7 +4,6 @@ namespace DigiComp\FlowSessionLock\Tests\Functional; use DigiComp\FlowSessionLock\Tests\Functional\Fixtures\Controller\ExampleController; use GuzzleHttp\Psr7\Uri; -use Neos\Flow\Composer\ComposerUtility; use Neos\Flow\Http\Cookie; use Neos\Flow\Mvc\Routing\Route; use Neos\Flow\Tests\FunctionalTestCase; From deddac89adae3b5b27e10861d521db7b8c1f7005 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Tue, 30 Aug 2022 14:43:13 +0200 Subject: [PATCH 21/22] Adding functional tests --- .woodpecker/functional-tests.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .woodpecker/functional-tests.yml diff --git a/.woodpecker/functional-tests.yml b/.woodpecker/functional-tests.yml new file mode 100644 index 0000000..02969f7 --- /dev/null +++ b/.woodpecker/functional-tests.yml @@ -0,0 +1,25 @@ +workspace: + base: /woodpecker + path: package + +matrix: + FLOW_VERSION: + - 7.3 + +pipeline: + functional-tests: + image: thecodingmachine/php:7.4-v4-cli + environment: + # Enable the PDO_SQLITE extension + - "PHP_EXTENSION_PDO_SQLITE=1" + - "FLOW_VERSION=${FLOW_VERSION}" + - "NEOS_BUILD_DIR=/woodpecker/Build-${FLOW_VERSION}" + commands: + - "sudo mkdir $NEOS_BUILD_DIR" + - "sudo chown -R docker:docker $NEOS_BUILD_DIR" + - "cd $NEOS_BUILD_DIR" + - "composer create-project --no-install neos/flow-base-distribution:^$FLOW_VERSION ." + - "composer config repositories.repo-name path /woodpecker/package" + - "composer config --no-plugins allow-plugins.neos/composer-plugin true" + - "composer require digicomp/flowsessionlock:@dev" + - "bin/phpunit --configuration Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/DigiComp.FlowSessionLock/Tests/Functional" From a9487d312d76ad6f2d85c3c8174d5199e863158a Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Tue, 30 Aug 2022 14:46:03 +0200 Subject: [PATCH 22/22] Adding build status to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0717b21..a35537f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ DigiComp.FlowSessionLock ------------------------ +![Build status](https://ci.digital-competence.de/api/badges/Packages/DigiComp.FlowSessionLock/status.svg) + By default, the session established by Flow is not "protected" in any way. This package restricts every request to load the session only, if there are no other requests having it in access currently. It allows to set custom pointcut which will set the session in "ReadOnly" mode, which allows concurrent requests to read, but disallows the current request to