Skip to content

Commit 0487361

Browse files
committed
add more tests.
1 parent 0d62ee9 commit 0487361

4 files changed

Lines changed: 27 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ $settings = array(
339339
'url' => '',
340340
// URL location of the IdP where SLO Response will be sent (ResponseLocation)
341341
// if not set, url for the SLO Request will be used
342-
'urlResponse' => '',
342+
'responseUrl' => '',
343343
// SAML protocol binding to be used when returning the <Response>
344344
// message. OneLogin Toolkit supports the HTTP-Redirect binding
345345
// only for this endpoint.

settings_example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +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 SLO Response will be sent (ResponseLocation)
96+
// URL location of the IdP where the SP SLO Response will be sent (ResponseLocation)
9797
// if not set, url for the SLO Request will be used
98-
'urlResponse' => '',
98+
'responseUrl' => '',
9999
// SAML protocol binding to be used when returning the <Response>
100100
// message. Onelogin Toolkit supports for this endpoint the
101101
// HTTP-Redirect binding only

tests/src/OneLogin/Saml2/AuthTest.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ public function testGetSLOurl()
9292
$this->assertEquals($this->_auth->getSLOurl(), $sloUrl);
9393
}
9494

95+
/**
96+
* Tests the getSLOResponseUrl method of the Auth class
97+
*
98+
* @covers OneLogin\Saml2\Auth::getSLOurl
99+
*/
100+
public function testGetSLOResponseUrl()
101+
{
102+
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
103+
$this->assertEquals($this->_auth->getSLOResponseUrl(), $sloUrl);
104+
}
105+
106+
95107
/**
96108
* Tests the processResponse method of the Auth class
97109
* Case No Response, An exception is throw
@@ -704,8 +716,8 @@ public function testProcessSLORequestDeletingSession()
704716
$targetUrl = getUrlFromRedirect($trace);
705717
$parsedQuery = getParamsFromUrl($targetUrl);
706718

707-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
708-
$this->assertContains($sloUrl, $targetUrl);
719+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
720+
$this->assertContains($sloResponseUrl, $targetUrl);
709721
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
710722
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
711723

@@ -725,8 +737,8 @@ public function testProcessSLORequestDeletingSession()
725737
$targetUrl = getUrlFromRedirect($trace);
726738
$parsedQuery = getParamsFromUrl($targetUrl);
727739

728-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
729-
$this->assertContains($sloUrl, $targetUrl);
740+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
741+
$this->assertContains($sloResponseUrl, $targetUrl);
730742
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
731743
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
732744

@@ -778,8 +790,8 @@ public function testProcessSLORequestDeletingSessionCallback()
778790
$targetUrl = getUrlFromRedirect($trace);
779791
$parsedQuery = getParamsFromUrl($targetUrl);
780792

781-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
782-
$this->assertContains($sloUrl, $targetUrl);
793+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];;;
794+
$this->assertContains($sloResponseUrl, $targetUrl);
783795
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
784796
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
785797

@@ -828,8 +840,8 @@ public function testProcessSLORequestRelayState()
828840
$targetUrl = getUrlFromRedirect($trace);
829841
$parsedQuery = getParamsFromUrl($targetUrl);
830842

831-
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
832-
$this->assertContains($sloUrl, $targetUrl);
843+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
844+
$this->assertContains($sloResponseUrl, $targetUrl);
833845
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
834846
$this->assertArrayHasKey('RelayState', $parsedQuery);
835847
$this->assertEquals('http://relaystate.com', $parsedQuery['RelayState']);
@@ -876,8 +888,8 @@ public function testProcessSLORequestSignedResponse()
876888
$targetUrl = getUrlFromRedirect($trace);
877889
$parsedQuery = getParamsFromUrl($targetUrl);
878890

879-
$sloUrl = $settingsInfo['idp']['singleLogoutService']['url'];
880-
$this->assertContains($sloUrl, $targetUrl);
891+
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
892+
$this->assertContains($sloResponseUrl, $targetUrl);
881893
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
882894
$this->assertArrayHasKey('RelayState', $parsedQuery);
883895
$this->assertArrayHasKey('SigAlg', $parsedQuery);

tests/src/OneLogin/Saml2/SettingsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ public function testCheckSettings()
316316
$settingsInfo['idp']['entityID'] = 'entityId';
317317
$settingsInfo['idp']['singleSignOnService']['url'] = 'invalid_value';
318318
$settingsInfo['idp']['singleLogoutService']['url'] = 'invalid_value';
319+
$settingsInfo['idp']['singleLogoutService']['responseUrl'] = 'invalid_value';
319320
$settingsInfo['sp']['assertionConsumerService']['url'] = 'invalid_value';
320321
$settingsInfo['sp']['singleLogoutService']['url'] = 'invalid_value';
321322
try {
@@ -324,6 +325,7 @@ public function testCheckSettings()
324325
} catch (Error $e) {
325326
$this->assertContains('idp_sso_url_invalid', $e->getMessage());
326327
$this->assertContains('idp_slo_url_invalid', $e->getMessage());
328+
$this->assertContains('idp_slo_response_url_invalid', $e->getMessage());
327329
$this->assertContains('sp_acs_url_invalid', $e->getMessage());
328330
$this->assertContains('sp_sls_url_invalid', $e->getMessage());
329331
}

0 commit comments

Comments
 (0)