| Línea 136... |
Línea 136... |
| 136 |
EOD;
|
136 |
EOD;
|
| Línea 137... |
Línea 137... |
| 137 |
|
137 |
|
| 138 |
/**
|
138 |
/**
|
| 139 |
* Test the mapping from Registration JSON to LTI Config for a has-it-all tool registration.
|
139 |
* Test the mapping from Registration JSON to LTI Config for a has-it-all tool registration.
|
| 140 |
*/
|
140 |
*/
|
| 141 |
public function test_to_config_full() {
|
141 |
public function test_to_config_full(): void {
|
| 142 |
$registration = json_decode($this->registrationfulljson, true);
|
142 |
$registration = json_decode($this->registrationfulljson, true);
|
| 143 |
$registration['scope'] .= ' https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly';
|
143 |
$registration['scope'] .= ' https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly';
|
| 144 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
144 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 145 |
$this->assertEquals('JWK_KEYSET', $config->lti_keytype);
|
145 |
$this->assertEquals('JWK_KEYSET', $config->lti_keytype);
|
| Línea 166... |
Línea 166... |
| 166 |
}
|
166 |
}
|
| Línea 167... |
Línea 167... |
| 167 |
|
167 |
|
| 168 |
/**
|
168 |
/**
|
| 169 |
* Test the mapping from Registration JSON to LTI Config for a minimal tool registration.
|
169 |
* Test the mapping from Registration JSON to LTI Config for a minimal tool registration.
|
| 170 |
*/
|
170 |
*/
|
| 171 |
public function test_to_config_minimal() {
|
171 |
public function test_to_config_minimal(): void {
|
| 172 |
$registration = json_decode($this->registrationminimaljson, true);
|
172 |
$registration = json_decode($this->registrationminimaljson, true);
|
| 173 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
173 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 174 |
$this->assertEquals('JWK_KEYSET', $config->lti_keytype);
|
174 |
$this->assertEquals('JWK_KEYSET', $config->lti_keytype);
|
| 175 |
$this->assertEquals(LTI_VERSION_1P3, $config->lti_ltiversion);
|
175 |
$this->assertEquals(LTI_VERSION_1P3, $config->lti_ltiversion);
|
| Línea 194... |
Línea 194... |
| 194 |
|
194 |
|
| 195 |
/**
|
195 |
/**
|
| 196 |
* Test the mapping from Registration JSON to LTI Config for a minimal tool with
|
196 |
* Test the mapping from Registration JSON to LTI Config for a minimal tool with
|
| 197 |
* deep linking support registration.
|
197 |
* deep linking support registration.
|
| 198 |
*/
|
198 |
*/
|
| 199 |
public function test_to_config_minimal_with_deeplinking() {
|
199 |
public function test_to_config_minimal_with_deeplinking(): void {
|
| 200 |
$registration = json_decode($this->registrationminimaldljson, true);
|
200 |
$registration = json_decode($this->registrationminimaldljson, true);
|
| 201 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
201 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 202 |
$this->assertEquals(1, $config->lti_contentitem);
|
202 |
$this->assertEquals(1, $config->lti_contentitem);
|
| 203 |
$this->assertEmpty($config->lti_toolurl_ContentItemSelectionRequest);
|
203 |
$this->assertEmpty($config->lti_toolurl_ContentItemSelectionRequest);
|
| Línea 204... |
Línea 204... |
| 204 |
}
|
204 |
}
|
| 205 |
|
205 |
|
| 206 |
/**
|
206 |
/**
|
| 207 |
* Validation Test: initiation login.
|
207 |
* Validation Test: initiation login.
|
| 208 |
*/
|
208 |
*/
|
| 209 |
public function test_validation_initlogin() {
|
209 |
public function test_validation_initlogin(): void {
|
| 210 |
$registration = json_decode($this->registrationfulljson, true);
|
210 |
$registration = json_decode($this->registrationfulljson, true);
|
| 211 |
$this->expectException(registration_exception::class);
|
211 |
$this->expectException(registration_exception::class);
|
| 212 |
$this->expectExceptionCode(400);
|
212 |
$this->expectExceptionCode(400);
|
| 213 |
unset($registration['initiate_login_uri']);
|
213 |
unset($registration['initiate_login_uri']);
|
| Línea 214... |
Línea 214... |
| 214 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
214 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 215 |
}
|
215 |
}
|
| 216 |
|
216 |
|
| 217 |
/**
|
217 |
/**
|
| 218 |
* Validation Test: redirect uris.
|
218 |
* Validation Test: redirect uris.
|
| 219 |
*/
|
219 |
*/
|
| 220 |
public function test_validation_redirecturis() {
|
220 |
public function test_validation_redirecturis(): void {
|
| 221 |
$registration = json_decode($this->registrationfulljson, true);
|
221 |
$registration = json_decode($this->registrationfulljson, true);
|
| 222 |
$this->expectException(registration_exception::class);
|
222 |
$this->expectException(registration_exception::class);
|
| 223 |
$this->expectExceptionCode(400);
|
223 |
$this->expectExceptionCode(400);
|
| Línea 224... |
Línea 224... |
| 224 |
unset($registration['redirect_uris']);
|
224 |
unset($registration['redirect_uris']);
|
| 225 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
225 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 226 |
}
|
226 |
}
|
| 227 |
|
227 |
|
| 228 |
/**
|
228 |
/**
|
| 229 |
* Validation Test: jwks uri empty.
|
229 |
* Validation Test: jwks uri empty.
|
| 230 |
*/
|
230 |
*/
|
| 231 |
public function test_validation_jwks() {
|
231 |
public function test_validation_jwks(): void {
|
| 232 |
$registration = json_decode($this->registrationfulljson, true);
|
232 |
$registration = json_decode($this->registrationfulljson, true);
|
| 233 |
$this->expectException(registration_exception::class);
|
233 |
$this->expectException(registration_exception::class);
|
| Línea 234... |
Línea 234... |
| 234 |
$this->expectExceptionCode(400);
|
234 |
$this->expectExceptionCode(400);
|
| 235 |
$registration['jwks_uri'] = '';
|
235 |
$registration['jwks_uri'] = '';
|
| 236 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
236 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 237 |
}
|
237 |
}
|
| 238 |
|
238 |
|
| 239 |
/**
|
239 |
/**
|
| 240 |
* Validation Test: no domain nor targetlinkuri is rejected.
|
240 |
* Validation Test: no domain nor targetlinkuri is rejected.
|
| 241 |
*/
|
241 |
*/
|
| 242 |
public function test_validation_missing_domain_targetlinkuri() {
|
242 |
public function test_validation_missing_domain_targetlinkuri(): void {
|
| Línea 249... |
Línea 249... |
| 249 |
}
|
249 |
}
|
| Línea 250... |
Línea 250... |
| 250 |
|
250 |
|
| 251 |
/**
|
251 |
/**
|
| 252 |
* Validation Test: mismatch between domain and targetlinkuri is rejected.
|
252 |
* Validation Test: mismatch between domain and targetlinkuri is rejected.
|
| 253 |
*/
|
253 |
*/
|
| 254 |
public function test_validation_domain_targetlinkuri_match() {
|
254 |
public function test_validation_domain_targetlinkuri_match(): void {
|
| 255 |
$registration = json_decode($this->registrationminimaljson, true);
|
255 |
$registration = json_decode($this->registrationminimaljson, true);
|
| 256 |
$this->expectException(registration_exception::class);
|
256 |
$this->expectException(registration_exception::class);
|
| 257 |
$this->expectExceptionCode(400);
|
257 |
$this->expectExceptionCode(400);
|
| 258 |
$registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['domain'] = 'not.the.right.domain';
|
258 |
$registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['domain'] = 'not.the.right.domain';
|
| 259 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
259 |
registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| Línea 260... |
Línea 260... |
| 260 |
}
|
260 |
}
|
| 261 |
|
261 |
|
| 262 |
/**
|
262 |
/**
|
| 263 |
* Validation Test: domain is required.
|
263 |
* Validation Test: domain is required.
|
| 264 |
*/
|
264 |
*/
|
| 265 |
public function test_validation_domain_targetlinkuri_onlylink() {
|
265 |
public function test_validation_domain_targetlinkuri_onlylink(): void {
|
| 266 |
$registration = json_decode($this->registrationminimaljson, true);
|
266 |
$registration = json_decode($this->registrationminimaljson, true);
|
| 267 |
unset($registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['domain']);
|
267 |
unset($registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['domain']);
|
| 268 |
$this->expectException(registration_exception::class);
|
268 |
$this->expectException(registration_exception::class);
|
| 269 |
$this->expectExceptionCode(400);
|
269 |
$this->expectExceptionCode(400);
|
| Línea 270... |
Línea 270... |
| 270 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
270 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| 271 |
}
|
271 |
}
|
| 272 |
|
272 |
|
| 273 |
/**
|
273 |
/**
|
| 274 |
* Validation Test: base url (targetlinkuri) is built from domain if not present.
|
274 |
* Validation Test: base url (targetlinkuri) is built from domain if not present.
|
| 275 |
*/
|
275 |
*/
|
| 276 |
public function test_validation_domain_targetlinkuri_onlydomain() {
|
276 |
public function test_validation_domain_targetlinkuri_onlydomain(): void {
|
| 277 |
$registration = json_decode($this->registrationminimaljson, true);
|
277 |
$registration = json_decode($this->registrationminimaljson, true);
|
| 278 |
unset($registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['target_link_uri']);
|
278 |
unset($registration['https://purl.imsglobal.org/spec/lti-tool-configuration']['target_link_uri']);
|
| 279 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
279 |
$config = registration_helper::get()->registration_to_config($registration, 'TheClientId');
|
| Línea 280... |
Línea 280... |
| 280 |
$this->assertEquals('example.org', $config->lti_tooldomain);
|
280 |
$this->assertEquals('example.org', $config->lti_tooldomain);
|
| 281 |
$this->assertEquals('https://www.example.org', $config->lti_toolurl);
|
281 |
$this->assertEquals('https://www.example.org', $config->lti_toolurl);
|
| 282 |
}
|
282 |
}
|
| 283 |
|
283 |
|
| 284 |
/**
|
284 |
/**
|
| 285 |
* Test the transformation from lti config to OpenId LTI Client Registration response.
|
285 |
* Test the transformation from lti config to OpenId LTI Client Registration response.
|
| 286 |
*/
|
286 |
*/
|
| 287 |
public function test_config_to_registration() {
|
287 |
public function test_config_to_registration(): void {
|
| 288 |
$orig = json_decode($this->registrationfulljson, true);
|
288 |
$orig = json_decode($this->registrationfulljson, true);
|
| Línea 320... |
Línea 320... |
| 320 |
}
|
320 |
}
|
| Línea 321... |
Línea 321... |
| 321 |
|
321 |
|
| 322 |
/**
|
322 |
/**
|
| 323 |
* Test the transformation from lti config to OpenId LTI Client Registration response for the minimal version.
|
323 |
* Test the transformation from lti config to OpenId LTI Client Registration response for the minimal version.
|
| 324 |
*/
|
324 |
*/
|
| 325 |
public function test_config_to_registration_minimal() {
|
325 |
public function test_config_to_registration_minimal(): void {
|
| 326 |
$orig = json_decode($this->registrationminimaljson, true);
|
326 |
$orig = json_decode($this->registrationminimaljson, true);
|
| 327 |
$reghelper = registration_helper::get();
|
327 |
$reghelper = registration_helper::get();
|
| 328 |
$reg = $reghelper->config_to_registration($reghelper->registration_to_config($orig, 'clid'), 12);
|
328 |
$reg = $reghelper->config_to_registration($reghelper->registration_to_config($orig, 'clid'), 12);
|
| 329 |
$this->assertEquals('clid', $reg['client_id']);
|
329 |
$this->assertEquals('clid', $reg['client_id']);
|
| Línea 343... |
Línea 343... |
| 343 |
}
|
343 |
}
|
| Línea 344... |
Línea 344... |
| 344 |
|
344 |
|
| 345 |
/**
|
345 |
/**
|
| 346 |
* Test the transformation from lti config 1.1 to Registration Response.
|
346 |
* Test the transformation from lti config 1.1 to Registration Response.
|
| 347 |
*/
|
347 |
*/
|
| 348 |
public function test_config_to_registration_lti11() {
|
348 |
public function test_config_to_registration_lti11(): void {
|
| 349 |
$config = [];
|
349 |
$config = [];
|
| 350 |
$config['contentitem'] = 1;
|
350 |
$config['contentitem'] = 1;
|
| 351 |
$config['toolurl_ContentItemSelectionRequest'] = '';
|
351 |
$config['toolurl_ContentItemSelectionRequest'] = '';
|
| 352 |
$config['sendname'] = 0;
|
352 |
$config['sendname'] = 0;
|
| Línea 387... |
Línea 387... |
| 387 |
|
387 |
|
| 388 |
/**
|
388 |
/**
|
| 389 |
* Test the transformation from lti config 2.0 to Registration Response.
|
389 |
* Test the transformation from lti config 2.0 to Registration Response.
|
| 390 |
* For LTI 2.0 we limit to just passing the previous key/secret.
|
390 |
* For LTI 2.0 we limit to just passing the previous key/secret.
|
| 391 |
*/
|
391 |
*/
|
| 392 |
public function test_config_to_registration_lti20() {
|
392 |
public function test_config_to_registration_lti20(): void {
|
| 393 |
$config = [];
|
393 |
$config = [];
|
| 394 |
$config['contentitem'] = 1;
|
394 |
$config['contentitem'] = 1;
|
| 395 |
$config['toolurl_ContentItemSelectionRequest'] = '';
|
395 |
$config['toolurl_ContentItemSelectionRequest'] = '';
|
| 396 |
$type = [];
|
396 |
$type = [];
|