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
13
13
public const ERROR_MSG_LAUNCH_URL = 'No launch URL configured ' ;
14
14
public const ERROR_MSG_ISSUER = 'Could not find issuer ' ;
15
15
public const ERROR_MSG_LOGIN_HINT = 'Could not find login hint ' ;
16
- public const ERROR_MSG_REGISTRATION = 'Could not find registration details ' ;
17
16
18
17
private $ db ;
19
18
private $ cache ;
@@ -113,11 +112,14 @@ public function validateOidcLogin($request)
113
112
}
114
113
115
114
// 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 );
117
117
118
118
// Check we got something.
119
119
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 );
121
123
}
122
124
123
125
// Return Registration.
Original file line number Diff line number Diff line change 6
6
use Packback \Lti1p3 \Interfaces \ICache ;
7
7
use Packback \Lti1p3 \Interfaces \ICookie ;
8
8
use Packback \Lti1p3 \Interfaces \IDatabase ;
9
+ use Packback \Lti1p3 \LtiMessageLaunch ;
9
10
use Packback \Lti1p3 \LtiOidcLogin ;
10
11
use Packback \Lti1p3 \OidcException ;
11
12
@@ -84,6 +85,10 @@ public function testValidatesFailsIfLoginHintIsNotSet()
84
85
$ this ->oidcLogin ->validateOidcLogin ($ request );
85
86
}
86
87
88
+ /**
89
+ * @runInSeparateProcess
90
+ * @preserveGlobalState disabled
91
+ */
87
92
public function testValidatesFailsIfRegistrationNotFound ()
88
93
{
89
94
$ request = [
@@ -93,8 +98,14 @@ public function testValidatesFailsIfRegistrationNotFound()
93
98
$ this ->database ->shouldReceive ('findRegistrationByIssuer ' )
94
99
->once ()->andReturn (null );
95
100
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
+
96
107
$ this ->expectException (OidcException::class);
97
- $ this ->expectExceptionMessage (LtiOidcLogin:: ERROR_MSG_REGISTRATION );
108
+ $ this ->expectExceptionMessage ($ expectedError );
98
109
99
110
$ this ->oidcLogin ->validateOidcLogin ($ request );
100
111
}
You can’t perform that action at this time.
0 commit comments