|
3 | 3 | namespace OneLogin\Saml2\Tests; |
4 | 4 |
|
5 | 5 | use OneLogin\Saml2\Error; |
| 6 | +use OneLogin\Saml2\Metadata; |
6 | 7 | use OneLogin\Saml2\Settings; |
7 | 8 | use OneLogin\Saml2\Utils; |
8 | 9 |
|
@@ -474,6 +475,35 @@ public function getSPMetadataWithX509CertNewDataProvider() |
474 | 475 | ]; |
475 | 476 | } |
476 | 477 |
|
| 478 | + /** |
| 479 | + * Tests the getSPMetadata method of the OneLogin_Saml2_Settings |
| 480 | + * Case ValidUntil CacheDuration |
| 481 | + * |
| 482 | + * @covers OneLogin\Saml2\Settings::getSPMetadata |
| 483 | + */ |
| 484 | + public function testGetSPMetadataTiming() |
| 485 | + { |
| 486 | + $settingsDir = TEST_ROOT .'/settings/'; |
| 487 | + include $settingsDir.'settings1.php'; |
| 488 | + |
| 489 | + $settings = new Settings($settingsInfo); |
| 490 | + |
| 491 | + $currentValidUntil = time() + Metadata::TIME_VALID; |
| 492 | + $currentValidUntilStr = gmdate('Y-m-d\TH:i:s\Z', $currentValidUntil); |
| 493 | + $defaultCacheDuration = Metadata::TIME_CACHED; |
| 494 | + |
| 495 | + $metadata = $settings->getSPMetadata(); |
| 496 | + $this->assertContains('validUntil="'.$currentValidUntilStr.'"', $metadata); |
| 497 | + $this->assertContains('cacheDuration="PT604800S"', $metadata); |
| 498 | + |
| 499 | + $newValidUntil = 2524668343; |
| 500 | + $newValidUntilStr = gmdate('Y-m-d\TH:i:s\Z', $newValidUntil); |
| 501 | + $newCacheDuration = 1209600; |
| 502 | + $metadata2 = $settings->getSPMetadata(false, $newValidUntil, $newCacheDuration); |
| 503 | + $this->assertContains('validUntil="'.$newValidUntilStr.'"', $metadata2); |
| 504 | + $this->assertContains('cacheDuration="PT1209600S"', $metadata2); |
| 505 | + } |
| 506 | + |
477 | 507 | /** |
478 | 508 | * Tests the getSPMetadata method of the Settings |
479 | 509 | * Case signed metadata |
|
0 commit comments