From 47463d74350ff86a08bd80457ee95c5664162d4e Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 16 Nov 2023 20:21:26 +0100 Subject: [PATCH] Fix sessionserver/join endpoint: return empty response with 204 status code on success join --- api/modules/session/controllers/SessionController.php | 9 ++++----- api/tests/functional/_steps/SessionServerSteps.php | 2 +- api/tests/functional/sessionserver/JoinCest.php | 9 +++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/api/modules/session/controllers/SessionController.php b/api/modules/session/controllers/SessionController.php index e00b3d8..d95d581 100644 --- a/api/modules/session/controllers/SessionController.php +++ b/api/modules/session/controllers/SessionController.php @@ -34,19 +34,18 @@ class SessionController extends Controller { } /** - * @return array * @throws ForbiddenOperationException * @throws IllegalArgumentException */ - public function actionJoin(): array { - Yii::$app->response->format = Response::FORMAT_JSON; - + public function actionJoin(Response $response): void { $data = Yii::$app->request->post(); $protocol = new ModernJoin($data['accessToken'] ?? '', $data['selectedProfile'] ?? '', $data['serverId'] ?? ''); $joinForm = new JoinForm($protocol); $joinForm->join(); // will throw an exception in case of any error - return ['id' => 'OK']; + $response->statusCode = 204; + $response->format = Response::FORMAT_RAW; + $response->content = ''; } public function actionJoinLegacy(): string { diff --git a/api/tests/functional/_steps/SessionServerSteps.php b/api/tests/functional/_steps/SessionServerSteps.php index adec3a0..346f127 100644 --- a/api/tests/functional/_steps/SessionServerSteps.php +++ b/api/tests/functional/_steps/SessionServerSteps.php @@ -30,7 +30,7 @@ class SessionServerSteps extends FunctionalTester { 'serverId' => $serverId, ]); - $this->canSeeResponseContainsJson(['id' => 'OK']); + $this->seeResponseCodeIs(204); } return [$username, $serverId]; diff --git a/api/tests/functional/sessionserver/JoinCest.php b/api/tests/functional/sessionserver/JoinCest.php index 76391dd..fd7fddb 100644 --- a/api/tests/functional/sessionserver/JoinCest.php +++ b/api/tests/functional/sessionserver/JoinCest.php @@ -150,12 +150,9 @@ class JoinCest { ]); } - private function expectSuccessResponse(FunctionalTester $I) { - $I->seeResponseCodeIs(200); - $I->seeResponseIsJson(); - $I->canSeeResponseContainsJson([ - 'id' => 'OK', - ]); + private function expectSuccessResponse(FunctionalTester $I): void { + $I->seeResponseCodeIs(204); + $I->canSeeResponseEquals(''); } }