From 426644e4536bb609782555b5627450fa4ed43dd8 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 --- lib/Command/CirclesCheck.php | 3 +++ lib/Controller/EventWrapperController.php | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Command/CirclesCheck.php b/lib/Command/CirclesCheck.php index 10b19821d..25f31ce12 100644 --- a/lib/Command/CirclesCheck.php +++ b/lib/Command/CirclesCheck.php @@ -59,6 +59,7 @@ use OCA\Circles\Tools\Traits\TNCRequest; use OCA\Circles\Tools\Traits\TStringTools; use OCP\IAppConfig; +use OCP\IConfig; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -86,6 +87,7 @@ class CirclesCheck extends Base { public function __construct( private Capabilities $capabilities, private IAppConfig $appConfig, + private IConfig $config, private InterfaceService $interfaceService, private FederatedEventService $federatedEventService, private RemoteService $remoteService, @@ -278,6 +280,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 bc3f41b08..64a874520 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([], 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();