Skip to content

Commit

Permalink
Merge branch 'release-15.19.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Apr 22, 2024
2 parents d2d26ad + 81110bc commit 9888f93
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public function authenticate(
/**
* @throws ErrorException
*/
private function getUserIdentity(string $userId): UserIdentity
private function getUserIdentity(string $userId): ?UserIdentity
{
// anonymous user without login data
if ($userId === '') {
return null;
}

$user = $this->getUserService()
->getUser($userId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class Lti1p3UserAuthenticatorTest extends TestCase
{
use ServiceManagerMockTrait;

private const LOGIN_HINT = 'userId#123456';

/** @var Lti1p3UserAuthenticator */
private $subject;
private Lti1p3UserAuthenticator $subject;

/** @var UserService|MockObject */
private $userService;
Expand Down Expand Up @@ -85,7 +87,7 @@ public function testAuthenticateUser(): void
'en-US'
)
),
$this->subject->authenticate($registration, 'userId#123456')
$this->subject->authenticate($registration, self::LOGIN_HINT)
);
}

Expand All @@ -104,12 +106,32 @@ public function testAnonymousOrGuestUser(): void
new UserAuthenticationResult(
true,
new UserIdentity(
'userId#123456',
self::LOGIN_HINT,
'',
''
)
),
$this->subject->authenticate($registration, 'userId#123456')
$this->subject->authenticate($registration, self::LOGIN_HINT)
);
}

public function testAnonymousWithoutLoginHintData(): void
{
$this->expectAnonymousUser(
[
'role'
]
);

/** @var RegistrationInterface|MockObject $registration */
$registration = $this->createMock(RegistrationInterface::class);

$this->assertEquals(
new UserAuthenticationResult(
true,
null
),
$this->subject->authenticate($registration, '')
);
}

Expand Down

0 comments on commit 9888f93

Please sign in to comment.