File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -154,11 +154,13 @@ public function cors($path) {
154154 public function authorize () {
155155 // Create a request
156156 if (!$ this ->userManager ->userExists ($ this ->userId )) {
157- $ result = new JSONResponse ('Authorization required ' );
158- $ result ->setStatus (401 );
159- return $ result ;
160- // return $result->addHeader('Access-Control-Allow-Origin', '*');
157+ return new JSONResponse ('Authorization required ' , 401 );
158+ }
159+
160+ if (! isset ($ _GET ['client_id ' ])) {
161+ return new JSONResponse ('Bad request, missing client_id ' , 400 );
161162 }
163+ $ clientId = $ _GET ['client_id ' ];
162164
163165 if (isset ($ _GET ['request ' ])) {
164166 $ jwtConfig = Configuration::forSymmetricSigner (new Sha256 (), InMemory::plainText ($ this ->config ->getPrivateKey ()));
Original file line number Diff line number Diff line change @@ -115,6 +115,25 @@ public function testAuthorizeWithoutUser()
115115 $ this ->assertEquals ($ expected , $ actual );
116116 }
117117
118+ /**
119+ * @testdox ServerController should return a 400 when asked to authorize with a user but without client_id
120+ *
121+ * @covers ::authorize
122+ */
123+ public function testAuthorizeWithoutClientId ()
124+ {
125+ $ parameters = $ this ->createMockConstructorParameters ();
126+
127+ $ parameters ['MockUserManager ' ]->method ('userExists ' )->willReturn (true );
128+
129+ $ controller = new ServerController (...array_values ($ parameters ));
130+
131+ $ actual = $ controller ->authorize ();
132+ $ expected = new JSONResponse ('Bad request, missing client_id ' , Http::STATUS_BAD_REQUEST );
133+
134+ $ this ->assertEquals ($ expected , $ actual );
135+ }
136+
118137 /**
119138 * @testdox ServerController should return a 400 when asked to authorize with a user but without valid token
120139 *
You can’t perform that action at this time.
0 commit comments