@@ -149,21 +149,6 @@ public function testGetClientRegistrationForNonExistingClient()
149149 $ this ->assertEquals ($ expected , $ actual );
150150 }
151151
152- /**
153- * @testdox BaseServerConfig should complain when asked to save ClientRegistration without origin
154- * @covers ::saveClientRegistration
155- */
156- public function testSaveClientRegistrationWithoutOrigin ()
157- {
158- $ this ->expectException (TypeError::class);
159- $ this ->expectExceptionMessage ('Too few arguments to function ' );
160-
161- $ configMock = $ this ->createMock (IConfig::class);
162- $ baseServerConfig = new BaseServerConfig ($ configMock );
163-
164- $ baseServerConfig ->saveClientRegistration ();
165- }
166-
167152 /**
168153 * @testdox BaseServerConfig should complain when asked to save ClientRegistration without client data
169154 * @covers ::saveClientRegistration
@@ -176,7 +161,7 @@ public function testSaveClientRegistrationWithoutClientData()
176161 $ configMock = $ this ->createMock (IConfig::class);
177162 $ baseServerConfig = new BaseServerConfig ($ configMock );
178163
179- $ baseServerConfig ->saveClientRegistration (self :: MOCK_ORIGIN );
164+ $ baseServerConfig ->saveClientRegistration ();
180165 }
181166
182167 /**
@@ -189,156 +174,61 @@ public function testSaveClientRegistrationForNewClient()
189174
190175 $ configMock ->expects ($ this ->once ())
191176 ->method ('getAppValue ' )
192- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
193177 ->willReturnArgument (2 );
194178
195- $ expected = [
196- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
197- 'client_name ' => self ::MOCK_ORIGIN ,
198- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
199- ];
200-
201- $ configMock ->expects ($ this ->exactly (2 ))
179+ $ configMock ->expects ($ this ->exactly (1 ))
202180 ->method ('setAppValue ' )
203181 ->willReturnMap ([
204182 // Using willReturnMap as withConsecutive is removed since PHPUnit 10
205- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
206- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
183+ [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ('{} ' )]
207184 ]);
208185
209186 $ baseServerConfig = new BaseServerConfig ($ configMock );
210187
211- $ actual = $ baseServerConfig ->saveClientRegistration (self :: MOCK_ORIGIN , []);
188+ $ actual = $ baseServerConfig ->saveClientRegistration ([]);
212189
213- $ this ->assertEquals ($ expected , $ actual );
190+ $ this ->assertArrayHasKey ('client_id ' , $ actual );
191+ $ this ->assertArrayHasKey ('client_secret ' , $ actual );
192+ $ this ->assertArrayHasKey ('client_name ' , $ actual );
214193 }
215194
216195 /**
217- * @testdox BaseServerConfig should save ClientRegistration when asked to save ClientRegistration for existing client
218- * @covers ::saveClientRegistration
196+ * @testdox BaseServerConfig should remove ClientRegistration when asked to remove ClientRegistration
197+ * @covers ::removeClientRegistration
219198 */
220- public function testSaveClientRegistrationForExistingClient ()
199+ public function testRemoveClientRegistration ()
221200 {
222201 $ configMock = $ this ->createMock (IConfig::class);
223-
224- $ expected = [
225- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
226- 'client_name ' => self ::MOCK_ORIGIN ,
227- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
228- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
229- ];
230-
231- $ configMock ->expects ($ this ->once ())
232- ->method ('getAppValue ' )
233- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
234- ->willReturn (json_encode ($ expected ));
235-
236- $ configMock ->expects ($ this ->exactly (2 ))
237- ->method ('setAppValue ' )
238- ->willReturnMap ([
239- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
240- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
241- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
242- ]);
243-
244202 $ baseServerConfig = new BaseServerConfig ($ configMock );
245203
246- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , []);
247-
248- $ this ->assertEquals ($ expected , $ actual );
249- }
250-
251- /**
252- * @testdox BaseServerConfig should save ClientRegistration when asked to save ClientRegistration for blocked client
253- * @covers ::saveClientRegistration
254- */
255- public function testSaveClientRegistrationForBlockedClient ()
256- {
257- $ configMock = $ this ->createMock (IConfig::class);
258-
259- $ expected = [
260- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
261- 'client_name ' => self ::MOCK_ORIGIN ,
262- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
263- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
264- 'blocked ' => true ,
265- ];
266-
267204 $ configMock ->expects ($ this ->once ())
268- ->method ('getAppValue ' )
269- ->with (Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ))
270- ->willReturn (json_encode ($ expected ));
271-
272- $ configMock ->expects ($ this ->exactly (2 ))
273- ->method ('setAppValue ' )
274- ->willReturnMap ([
275- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
276- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
277- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
278- ]);
279-
280- $ baseServerConfig = new BaseServerConfig ($ configMock );
281-
282- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , $ expected );
205+ ->method ('deleteAppValue ' )
206+ ->with (Application::APP_ID , 'client- ' . self ::MOCK_CLIENT_ID );
283207
284- $ this -> assertEquals ( $ expected , $ actual );
208+ $ baseServerConfig -> removeClientRegistration ( self :: MOCK_CLIENT_ID );
285209 }
286210
287211 /**
288- * @testdox BaseServerConfig should always "blocked" to existing value when asked to save ClientRegistration for blocked client
289- * @covers ::saveClientRegistration
212+ * @testdox BaseServerConfig should return decoded trusted apps when asked to GetTrustedApps
213+ * @covers ::getTrustedApps
290214 */
291- public function testSaveClientRegistrationSetsBlocked ()
215+ public function testGetTrustedApps ()
292216 {
293217 $ configMock = $ this ->createMock (IConfig::class);
218+ $ baseServerConfig = new BaseServerConfig ($ configMock );
294219
295- $ expected = [
296- 'client_id ' => md5 (self ::MOCK_ORIGIN ),
297- 'client_name ' => self ::MOCK_ORIGIN ,
298- 'client_secret ' => md5 (self ::MOCK_RANDOM_BYTES ),
299- 'redirect_uris ' => [self ::MOCK_REDIRECT_URI ],
300- 'blocked ' => true ,
301- ];
220+ $ expected = [self ::MOCK_ORIGIN ];
302221
303222 $ configMock ->expects ($ this ->once ())
304223 ->method ('getAppValue ' )
305- ->with (Application::APP_ID , 'client- ' . md5 ( self :: MOCK_ORIGIN ) )
224+ ->with (Application::APP_ID , 'trustedApps ' , ' [] ' )
306225 ->willReturn (json_encode ($ expected ));
307226
308- $ clientData = $ expected ;
309- $ clientData ['blocked ' ] = false ;
310-
311- $ configMock ->expects ($ this ->exactly (2 ))
312- ->method ('setAppValue ' )
313- ->willReturnMap ([
314- // Using willReturnMap as withConsecutive is deprecated since PHPUnit 10
315- [Application::APP_ID , 'client- ' . md5 (self ::MOCK_ORIGIN ), json_encode ($ expected )],
316- [Application::APP_ID , 'client- ' . self ::MOCK_ORIGIN , json_encode ($ expected )]
317- ]);
318-
319- $ baseServerConfig = new BaseServerConfig ($ configMock );
320-
321- $ actual = $ baseServerConfig ->saveClientRegistration (self ::MOCK_ORIGIN , $ clientData );
227+ $ actual = $ baseServerConfig ->getTrustedApps ();
322228
323229 $ this ->assertEquals ($ expected , $ actual );
324230 }
325231
326- /**
327- * @testdox BaseServerConfig should remove ClientRegistration when asked to remove ClientRegistration
328- * @covers ::removeClientRegistration
329- */
330- public function testRemoveClientRegistration ()
331- {
332- $ configMock = $ this ->createMock (IConfig::class);
333- $ baseServerConfig = new BaseServerConfig ($ configMock );
334-
335- $ configMock ->expects ($ this ->once ())
336- ->method ('deleteAppValue ' )
337- ->with (Application::APP_ID , 'client- ' . self ::MOCK_CLIENT_ID );
338-
339- $ baseServerConfig ->removeClientRegistration (self ::MOCK_CLIENT_ID );
340- }
341-
342232 /////////////////////////////// DATAPROVIDERS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
343233
344234 public function provideBooleans ()
0 commit comments