File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ class LtiOidcLogin
1313 public const ERROR_MSG_LAUNCH_URL = 'No launch URL configured ' ;
1414 public const ERROR_MSG_ISSUER = 'Could not find issuer ' ;
1515 public const ERROR_MSG_LOGIN_HINT = 'Could not find login hint ' ;
16- public const ERROR_MSG_REGISTRATION = 'Could not find registration details ' ;
1716
1817 private $ db ;
1918 private $ cache ;
@@ -113,11 +112,14 @@ public function validateOidcLogin($request)
113112 }
114113
115114 // Fetch Registration Details.
116- $ registration = $ this ->db ->findRegistrationByIssuer ($ request ['iss ' ], $ request ['client_id ' ] ?? null );
115+ $ clientId = $ request ['client_id ' ] ?? null ;
116+ $ registration = $ this ->db ->findRegistrationByIssuer ($ request ['iss ' ], $ clientId );
117117
118118 // Check we got something.
119119 if (empty ($ registration )) {
120- throw new OidcException (static ::ERROR_MSG_REGISTRATION , 1 );
120+ $ errorMsg = LtiMessageLaunch::getMissingRegistrationErrorMsg ($ request ['iss ' ], $ clientId );
121+
122+ throw new OidcException ($ errorMsg , 1 );
121123 }
122124
123125 // Return Registration.
Original file line number Diff line number Diff line change 66use Packback \Lti1p3 \Interfaces \ICache ;
77use Packback \Lti1p3 \Interfaces \ICookie ;
88use Packback \Lti1p3 \Interfaces \IDatabase ;
9+ use Packback \Lti1p3 \LtiMessageLaunch ;
910use Packback \Lti1p3 \LtiOidcLogin ;
1011use Packback \Lti1p3 \OidcException ;
1112
@@ -84,6 +85,10 @@ public function testValidatesFailsIfLoginHintIsNotSet()
8485 $ this ->oidcLogin ->validateOidcLogin ($ request );
8586 }
8687
88+ /**
89+ * @runInSeparateProcess
90+ * @preserveGlobalState disabled
91+ */
8792 public function testValidatesFailsIfRegistrationNotFound ()
8893 {
8994 $ request = [
@@ -93,8 +98,14 @@ public function testValidatesFailsIfRegistrationNotFound()
9398 $ this ->database ->shouldReceive ('findRegistrationByIssuer ' )
9499 ->once ()->andReturn (null );
95100
101+ // Use an alias to mock LtiMessageLaunch::getMissingRegistrationErrorMsg()
102+ $ expectedError = 'Registration not found! ' ;
103+ Mockery::mock ('alias: ' .LtiMessageLaunch::class)
104+ ->shouldReceive ('getMissingRegistrationErrorMsg ' )
105+ ->andReturn ($ expectedError );
106+
96107 $ this ->expectException (OidcException::class);
97- $ this ->expectExceptionMessage (LtiOidcLogin:: ERROR_MSG_REGISTRATION );
108+ $ this ->expectExceptionMessage ($ expectedError );
98109
99110 $ this ->oidcLogin ->validateOidcLogin ($ request );
100111 }
You can’t perform that action at this time.
0 commit comments