Skip to content

Commit 65565b4

Browse files
committed
Fix bug in ServerController::logout() caused by UserService not being set.
1 parent c070c76 commit 65565b4

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

solid/lib/Controller/ServerController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use OCA\Solid\DpopFactoryTrait;
55
use OCA\Solid\ServerConfig;
6+
use OCA\Solid\Service\UserService;
67

78
use OCP\AppFramework\Controller;
89
use OCP\AppFramework\Http;
@@ -47,6 +48,8 @@ class ServerController extends Controller
4748
/* @var \Pdsinterop\Solid\Auth\TokenGenerator */
4849
private $tokenGenerator;
4950

51+
private UserService $userService;
52+
5053
public function __construct(
5154
$AppName,
5255
IRequest $request,
@@ -55,7 +58,7 @@ public function __construct(
5558
IURLGenerator $urlGenerator,
5659
$userId,
5760
IConfig $config,
58-
\OCA\Solid\Service\UserService $UserService,
61+
UserService $userService,
5962
IDBConnection $connection,
6063
) {
6164
parent::__construct($AppName, $request);
@@ -66,6 +69,7 @@ public function __construct(
6669
$this->request = $request;
6770
$this->urlGenerator = $urlGenerator;
6871
$this->session = $session;
72+
$this->userService = $userService;
6973

7074
$this->setJtiStorage($connection);
7175

solid/tests/Unit/Controller/ServerControllerTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,29 @@ public function testToken()
450450
$this->assertEquals($expected, $actual);
451451
}
452452

453+
/**
454+
* @testdox ServerController should return an OK when asked to logout
455+
*
456+
* @covers ::logout
457+
*/
458+
public function testLogout() {
459+
$parameters = $this->createMockConstructorParameters();
460+
$index = self::provideConstructorParameterIndex();
461+
$mockUserService = $parameters[$index['userService'][0]];
462+
463+
$mockUserService->expects($this->once())
464+
->method('logout')
465+
->willReturn(null)
466+
;
467+
468+
$controller = new ServerController(...array_values($parameters));
469+
470+
$actual = $controller->logout();
471+
$expected = new JSONResponse('ok', Http::STATUS_OK);
472+
473+
$this->assertEquals($expected, $actual);
474+
}
475+
453476
////////////////////////////// MOCKS AND STUBS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
454477

455478
public function createMockConfig($clientData): IConfig|MockObject

0 commit comments

Comments
 (0)