ILIAS
trunk Revision v13.0_alpha-62-g3b72d83f2e5
◀ ilDoc Overview
SessionAuthenticatedSubjectResolverTest.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Tests\Authentication\KeyValueStorage
;
22
23
use
ILIAS\Authentication\Domain\AuthenticatedUser
;
24
use
ILIAS\Authentication\KeyValueStorage\AuthenticatedUserSubjectProvider
;
25
use
ILIAS\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolver
;
26
use
ILIAS\Data\Result
;
27
use
ILIAS\Data\Result\Error
;
28
use
ILIAS\Data\Result\Ok
;
29
use PHPUnit\Framework\TestCase;
30
31
class
SessionAuthenticatedSubjectResolverTest
extends
TestCase
32
{
33
public
function
testALoggedInUserBecomesTheSubjectOfItsIdAndMayPersist
(): void
34
{
35
$resolver
=
new
SessionAuthenticatedSubjectResolver
($this->
user
(
new
Ok
(42)),
new
AuthenticatedUserSubjectProvider
());
36
37
self::assertSame(
AuthenticatedUserSubjectProvider::NAME
,
$resolver
->subject()->id()->provider());
38
self::assertSame(
'42'
,
$resolver
->subject()->id()->id());
39
self::assertTrue(
$resolver
->supportsPersistentStorage());
40
}
41
42
public
function
testAnErrorBecomesAnonymousAndMayNotPersist
(): void
43
{
44
$resolver
=
new
SessionAuthenticatedSubjectResolver
(
45
$this->
user
(
new
Error
(
'No authenticated user in session.'
)),
46
new
AuthenticatedUserSubjectProvider
()
47
);
48
49
self::assertTrue(
$resolver
->subject()->isAnonymous());
50
self::assertFalse(
$resolver
->supportsPersistentStorage());
51
}
52
53
public
function
testANonPositiveIdBecomesAnonymousAndMayNotPersist
(): void
54
{
55
$resolver
=
new
SessionAuthenticatedSubjectResolver
($this->
user
(
new
Ok
(0)),
new
AuthenticatedUserSubjectProvider
());
56
57
self::assertTrue(
$resolver
->subject()->isAnonymous());
58
self::assertFalse(
$resolver
->supportsPersistentStorage());
59
}
60
61
private
function
user
(
Result
$id
):
AuthenticatedUser
62
{
63
$user = $this->createStub(AuthenticatedUser::class);
64
$user->method(
'id'
)->willReturn(
$id
);
65
66
return
$user;
67
}
68
}
$id
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition:
plugin.php:23
$resolver
foreach($components as $component) $resolver
Definition:
build_bootstrap.php:84
ILIAS\Authentication\KeyValueStorage\AuthenticatedUserSubjectProvider
Names the fully authenticated ILIAS users as KeyValueStorage subjects; the subject id is the user id.
Definition:
AuthenticatedUserSubjectProvider.php:34
ILIAS\Authentication\KeyValueStorage\AuthenticatedUserSubjectProvider\NAME
const string NAME
Definition:
AuthenticatedUserSubjectProvider.php:35
ILIAS\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolver
Maps {.
Definition:
SessionAuthenticatedSubjectResolver.php:31
ILIAS\Data\Result\Ok
A result encapsulates a value or an error and simplifies the handling of those.
Definition:
Ok.php:31
ILIAS\Tests\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolverTest
Definition:
SessionAuthenticatedSubjectResolverTest.php:32
ILIAS\Tests\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolverTest\testALoggedInUserBecomesTheSubjectOfItsIdAndMayPersist
testALoggedInUserBecomesTheSubjectOfItsIdAndMayPersist()
Definition:
SessionAuthenticatedSubjectResolverTest.php:33
ILIAS\Tests\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolverTest\testANonPositiveIdBecomesAnonymousAndMayNotPersist
testANonPositiveIdBecomesAnonymousAndMayNotPersist()
Definition:
SessionAuthenticatedSubjectResolverTest.php:53
ILIAS\Tests\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolverTest\testAnErrorBecomesAnonymousAndMayNotPersist
testAnErrorBecomesAnonymousAndMayNotPersist()
Definition:
SessionAuthenticatedSubjectResolverTest.php:42
ILIAS\Tests\Authentication\KeyValueStorage\SessionAuthenticatedSubjectResolverTest\user
user(Result $id)
Definition:
SessionAuthenticatedSubjectResolverTest.php:61
ILIAS\Authentication\Domain\AuthenticatedUser
Query port for a fully authenticated ILIAS user in the current request.
Definition:
AuthenticatedUser.php:32
ILIAS\Data\Result
A result encapsulates a value or an error and simplifies the handling of those.
Definition:
Result.php:29
ILIAS\Data\Result
Definition:
Error.php:21
ILIAS\MetaData\OERExposer\OAIPMH\Responses\Error
Error
Definition:
Error.php:24
ILIAS\Tests\Authentication\KeyValueStorage
Definition:
AuthenticatedSubjectPurgeTest.php:21
components
ILIAS
Authentication
tests
KeyValueStorage
SessionAuthenticatedSubjectResolverTest.php
Generated on Wed Nov 11 2026 23:05:37 for ILIAS by
1.9.4 (using
Doxyfile
)