From 4f266b9a67e1721d060f3a9979d97405c2818351 Mon Sep 17 00:00:00 2001 From: Jonathan Vuillemin Date: Wed, 25 Aug 2021 15:53:16 +0200 Subject: [PATCH] feat: proctoring claims --- src/Message/Payload/LtiMessagePayload.php | 11 ++++++++++- src/Message/Payload/LtiMessagePayloadInterface.php | 6 ++++++ src/Security/OAuth2/Repository/ClientRepository.php | 1 - tests/Unit/Message/Payload/LtiMessagePayloadTest.php | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Message/Payload/LtiMessagePayload.php b/src/Message/Payload/LtiMessagePayload.php index 512ef7c..93d1f0e 100644 --- a/src/Message/Payload/LtiMessagePayload.php +++ b/src/Message/Payload/LtiMessagePayload.php @@ -37,7 +37,6 @@ use OAT\Library\Lti1p3Core\Message\Payload\Claim\ProctoringVerifiedUserClaim; use OAT\Library\Lti1p3Core\Message\Payload\Claim\ResourceLinkClaim; use OAT\Library\Lti1p3Core\Role\Collection\RoleCollection; -use OAT\Library\Lti1p3Core\Role\Collection\RoleCollectionInterface; use OAT\Library\Lti1p3Core\Role\Factory\RoleFactory; use OAT\Library\Lti1p3Core\User\UserIdentity; use OAT\Library\Lti1p3Core\User\UserIdentityInterface; @@ -227,6 +226,16 @@ public function getProctoringEndAssessmentReturn(): bool return false; } + public function getProctoringErrorMessage(): ?string + { + return $this->getClaim(static::CLAIM_LTI_PROCTORING_ERROR_MESSAGE); + } + + public function getProctoringErrorLog(): ?string + { + return $this->getClaim(static::CLAIM_LTI_PROCTORING_ERROR_LOG); + } + public function getAcs(): ?AcsClaim { return $this->getClaim(AcsClaim::class); diff --git a/src/Message/Payload/LtiMessagePayloadInterface.php b/src/Message/Payload/LtiMessagePayloadInterface.php index 60deb5c..8a88c0c 100644 --- a/src/Message/Payload/LtiMessagePayloadInterface.php +++ b/src/Message/Payload/LtiMessagePayloadInterface.php @@ -73,6 +73,8 @@ interface LtiMessagePayloadInterface extends MessagePayloadInterface public const CLAIM_LTI_PROCTORING_ATTEMPT_NUMBER = 'https://purl.imsglobal.org/spec/lti-ap/claim/attempt_number'; public const CLAIM_LTI_PROCTORING_VERIFIED_USER = 'https://purl.imsglobal.org/spec/lti-ap/claim/verified_user'; public const CLAIM_LTI_PROCTORING_END_ASSESSMENT_RETURN = 'https://purl.imsglobal.org/spec/lti-ap/claim/end_assessment_return'; + public const CLAIM_LTI_PROCTORING_ERROR_MESSAGE = ' https://purl.imsglobal.org/spec/lti-ap/claim/errormsg'; + public const CLAIM_LTI_PROCTORING_ERROR_LOG = ' https://purl.imsglobal.org/spec/lti-ap/claim/errorlog '; // ACS claim public const CLAIM_LTI_ACS = 'https://purl.imsglobal.org/spec/lti-ap/claim/acs'; @@ -140,6 +142,10 @@ public function getProctoringVerifiedUser(): ?ProctoringVerifiedUserClaim; public function getProctoringEndAssessmentReturn(): bool; + public function getProctoringErrorMessage(): ?string; + + public function getProctoringErrorLog(): ?string; + public function getAcs(): ?AcsClaim; public function getAgs(): ?AgsClaim; diff --git a/src/Security/OAuth2/Repository/ClientRepository.php b/src/Security/OAuth2/Repository/ClientRepository.php index 6178a2d..4b49731 100644 --- a/src/Security/OAuth2/Repository/ClientRepository.php +++ b/src/Security/OAuth2/Repository/ClientRepository.php @@ -25,7 +25,6 @@ use League\OAuth2\Server\Entities\ClientEntityInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use OAT\Library\Lti1p3Core\Message\Payload\LtiMessagePayloadInterface; -use OAT\Library\Lti1p3Core\Message\Payload\MessagePayloadInterface; use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface; use OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcher; use OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcherInterface; diff --git a/tests/Unit/Message/Payload/LtiMessagePayloadTest.php b/tests/Unit/Message/Payload/LtiMessagePayloadTest.php index 7a7843a..3d6c65b 100644 --- a/tests/Unit/Message/Payload/LtiMessagePayloadTest.php +++ b/tests/Unit/Message/Payload/LtiMessagePayloadTest.php @@ -87,6 +87,8 @@ protected function setUp(): void ->withClaim(LtiMessagePayloadInterface::CLAIM_LTI_PROCTORING_ATTEMPT_NUMBER, '1') ->withClaim(LtiMessagePayloadInterface::CLAIM_LTI_PROCTORING_VERIFIED_USER, ['picture' => 'picture']) ->withClaim(LtiMessagePayloadInterface::CLAIM_LTI_PROCTORING_END_ASSESSMENT_RETURN, true) + ->withClaim(LtiMessagePayloadInterface::CLAIM_LTI_PROCTORING_ERROR_MESSAGE, 'proctoringErrorMessage') + ->withClaim(LtiMessagePayloadInterface::CLAIM_LTI_PROCTORING_ERROR_LOG, 'proctoringErrorLog') ->withClaim(new AcsClaim(['action'], 'assessmentControlUrl')) ->withClaim(new AgsClaim(['scope'], 'lineItemContainerUrl')) ->withClaim(new NrpsClaim('membershipUrl')) @@ -121,6 +123,8 @@ public function testClaims(): void $this->assertEquals('proctoringSettings', $this->subject->getProctoringSettings()->getData()); $this->assertEquals('proctoringSessionData', $this->subject->getProctoringSessionData()); $this->assertTrue($this->subject->getProctoringEndAssessmentReturn()); + $this->assertEquals('proctoringErrorMessage', $this->subject->getProctoringErrorMessage()); + $this->assertEquals('proctoringErrorLog', $this->subject->getProctoringErrorLog()); $this->assertEquals('1', $this->subject->getProctoringAttemptNumber()); $this->assertEquals(['picture' => 'picture'], $this->subject->getProctoringVerifiedUser()->getUserData()); $this->assertEquals(['action'], $this->subject->getAcs()->getActions());