From 62d2a4ae89de4703669e0d24dd1d6f02c24e7aae Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 18 Nov 2025 10:06:09 -0100 Subject: [PATCH] [stable29] allow test during :check Signed-off-by: Maxence Lange [skip ci] --- lib/Command/CirclesCheck.php | 1 + lib/Controller/EventWrapperController.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Command/CirclesCheck.php b/lib/Command/CirclesCheck.php index b5dcdb8a6..d879bfb97 100644 --- a/lib/Command/CirclesCheck.php +++ b/lib/Command/CirclesCheck.php @@ -333,6 +333,7 @@ private function testLoopback(InputInterface $input, OutputInterface $output): b return false; } + $this->config->setAppValue(Application::APP_ID, 'test_dummy_token', (string)(time() + 10)); if (!$this->testRequest( $output, 'POST', 'circles.EventWrapper.asyncBroadcast', ['token' => 'test-dummy-token'] diff --git a/lib/Controller/EventWrapperController.php b/lib/Controller/EventWrapperController.php index 0e09afe45..d04436648 100644 --- a/lib/Controller/EventWrapperController.php +++ b/lib/Controller/EventWrapperController.php @@ -42,6 +42,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; +use OCP\IConfig; use OCP\IRequest; /** @@ -68,7 +69,8 @@ class EventWrapperController extends Controller { /** @var ConfigService */ private $configService; - + /** @var IConfig */ + private $config; /** * EventWrapperController constructor. @@ -84,6 +86,7 @@ class EventWrapperController extends Controller { public function __construct( string $appName, IRequest $request, + IConfig $config, EventWrapperService $eventWrapperService, FederatedEventService $federatedEventService, RemoteUpstreamService $remoteUpstreamService, @@ -91,6 +94,7 @@ public function __construct( ConfigService $configService ) { parent::__construct($appName, $request); + $this->config = $config; $this->eventWrapperService = $eventWrapperService; $this->federatedEventService = $federatedEventService; $this->remoteUpstreamService = $remoteUpstreamService; @@ -121,6 +125,10 @@ public function asyncBroadcast(string $token): DataResponse { return new DataResponse(null, Http::STATUS_OK); } + if ($token === 'test-dummy-token' && ((int)$this->config->getAppValue(Application::APP_ID, 'test_dummy_token', '0')) < time()) { + return new DataResponse([], Http::STATUS_UNAUTHORIZED); + } + // closing socket, keep current process running. $this->async();