Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion solid/lib/Controller/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use OCA\Solid\DpopFactoryTrait;
use OCA\Solid\ServerConfig;
use OCA\Solid\Service\UserService;

use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
Expand Down Expand Up @@ -47,6 +48,8 @@ class ServerController extends Controller
/* @var \Pdsinterop\Solid\Auth\TokenGenerator */
private $tokenGenerator;

private UserService $userService;

public function __construct(
$AppName,
IRequest $request,
Expand All @@ -55,7 +58,7 @@ public function __construct(
IURLGenerator $urlGenerator,
$userId,
IConfig $config,
\OCA\Solid\Service\UserService $UserService,
UserService $userService,
IDBConnection $connection,
) {
parent::__construct($AppName, $request);
Expand All @@ -66,6 +69,7 @@ public function __construct(
$this->request = $request;
$this->urlGenerator = $urlGenerator;
$this->session = $session;
$this->userService = $userService;

$this->setJtiStorage($connection);

Expand Down
23 changes: 23 additions & 0 deletions solid/tests/Unit/Controller/ServerControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,29 @@ public function testToken()
$this->assertEquals($expected, $actual);
}

/**
* @testdox ServerController should return an OK when asked to logout
*
* @covers ::logout
*/
public function testLogout() {
$parameters = $this->createMockConstructorParameters();
$index = self::provideConstructorParameterIndex();
$mockUserService = $parameters[$index['userService'][0]];

$mockUserService->expects($this->once())
->method('logout')
->willReturn(null)
;

$controller = new ServerController(...array_values($parameters));

$actual = $controller->logout();
$expected = new JSONResponse('ok', Http::STATUS_OK);

$this->assertEquals($expected, $actual);
}

////////////////////////////// MOCKS AND STUBS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\

public function createMockConfig($clientData): IConfig|MockObject
Expand Down