Skip to content

Commit ecc1abc

Browse files
committed
add more tests
1 parent acf61a8 commit ecc1abc

6 files changed

Lines changed: 28 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ $settings = array (
375375
'singleLogoutService' => array (
376376
// URL Location of the IdP where SLO Request will be sent.
377377
'url' => '',
378+
// URL location of the IdP where the SP will send the SLO Response (ResponseLocation)
379+
// if not set, url for the SLO Request will be used
380+
'responseUrl' => '',
378381
// SAML protocol binding to be used when returning the <Response>
379382
// message. OneLogin Toolkit supports the HTTP-Redirect binding
380383
// only for this endpoint.

lib/Saml2/Auth.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ public function getSLOurl()
588588
*/
589589
public function getSLOResponseUrl()
590590
{
591-
$url = null;
592591
$idpData = $this->_settings->getIdPData();
593592
if (isset($idpData['singleLogoutService']) && isset($idpData['singleLogoutService']['responseUrl'])) {
594593
return $idpData['singleLogoutService']['responseUrl'];

settings_example.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
'singleLogoutService' => array (
9494
// URL Location of the IdP where the SP will send the SLO Request
9595
'url' => '',
96+
// URL location of the IdP where the SP will send the SLO Response (ResponseLocation)
97+
// if not set, url for the SLO Request will be used
98+
'responseUrl' => '',
9699
// SAML protocol binding to be used when returning the <Response>
97100
// message. Onelogin Toolkit supports for this endpoint the
98101
// HTTP-Redirect binding only

tests/settings/settings1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
),
2020
'singleLogoutService' => array (
2121
'url' => 'http://idp.example.com/SingleLogoutService.php',
22+
'responseUrl' => 'http://idp.example.com/SingleLogoutServiceResponse.php',
2223
),
2324
'x509cert' => 'MIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYDVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4MTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xiZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2ZlaWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5vMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LONoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHISKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8BUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2QarQ4/67OZfHd7R+POBXhophSMv1ZOo',
2425
),

tests/src/OneLogin/Saml2/AuthTest.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ public function testGetSLOurl()
7979
$this->assertEquals($this->_auth->getSLOurl(), $sloUrl);
8080
}
8181

82+
/**
83+
* Tests the getSLOResponseUrl method of the OneLogin_Saml2_Auth class
84+
*
85+
* @covers OneLogin_Saml2_Auth::getSLOurl
86+
*/
87+
public function testGetSLOResponseUrl()
88+
{
89+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
90+
$this->assertEquals($this->_auth->getSLOResponseUrl(), $sloResponseUrl);
91+
}
92+
8293
/**
8394
* Tests the processResponse method of the OneLogin_Saml2_Auth class
8495
* Case No Response, An exception is throw
@@ -548,8 +559,8 @@ public function testProcessSLORequestInvalidValid()
548559
$parsedQuery = getParamsFromUrl($targetUrl);
549560

550561
$this->assertEmpty($this->_auth->getErrors());
551-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
552-
$this->assertContains($sloUrl, $targetUrl);
562+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
563+
$this->assertContains($sloResponseUrl, $targetUrl);
553564
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
554565
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
555566
}
@@ -570,8 +581,8 @@ public function testProcessSLORequestInvalidValid()
570581
$parsedQuery = getParamsFromUrl($targetUrl);
571582

572583
$this->assertEmpty($this->_auth->getErrors());
573-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
574-
$this->assertContains($sloUrl, $targetUrl);
584+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
585+
$this->assertContains($sloResponseUrl, $targetUrl);
575586
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
576587
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
577588
}
@@ -636,8 +647,8 @@ public function testProcessSLORequestDeletingSession()
636647
$targetUrl = getUrlFromRedirect($trace);
637648
$parsedQuery = getParamsFromUrl($targetUrl);
638649

639-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
640-
$this->assertContains($sloUrl, $targetUrl);
650+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
651+
$this->assertContains($sloResponseUrl, $targetUrl);
641652
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
642653
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
643654

@@ -657,8 +668,8 @@ public function testProcessSLORequestDeletingSession()
657668
$targetUrl = getUrlFromRedirect($trace);
658669
$parsedQuery = getParamsFromUrl($targetUrl);
659670

660-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
661-
$this->assertContains($sloUrl, $targetUrl);
671+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
672+
$this->assertContains($sloResponseUrl, $targetUrl);
662673
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
663674
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
664675

tests/src/OneLogin/Saml2/SettingsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ public function testCheckSettings()
333333
$settingsInfo['idp']['entityID'] = 'entityId';
334334
$settingsInfo['idp']['singleSignOnService']['url'] = 'invalid_value';
335335
$settingsInfo['idp']['singleLogoutService']['url'] = 'invalid_value';
336+
$settingsInfo['idp']['singleLogoutService']['responseUrl'] = 'invalid_value';
336337
$settingsInfo['sp']['assertionConsumerService']['url'] = 'invalid_value';
337338
$settingsInfo['sp']['singleLogoutService']['url'] = 'invalid_value';
338339
try {
@@ -341,6 +342,7 @@ public function testCheckSettings()
341342
} catch (OneLogin_Saml2_error $e) {
342343
$this->assertContains('idp_sso_url_invalid', $e->getMessage());
343344
$this->assertContains('idp_slo_url_invalid', $e->getMessage());
345+
$this->assertContains('idp_slo_response_url_invalid', $e->getMessage());
344346
$this->assertContains('sp_acs_url_invalid', $e->getMessage());
345347
$this->assertContains('sp_sls_url_invalid', $e->getMessage());
346348
}

0 commit comments

Comments
 (0)