Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwey committed Feb 6, 2019
1 parent acf61a8 commit ecc1abc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ $settings = array (
'singleLogoutService' => array (
// URL Location of the IdP where SLO Request will be sent.
'url' => '',
// URL location of the IdP where the SP will send the SLO Response (ResponseLocation)
// if not set, url for the SLO Request will be used
'responseUrl' => '',
// SAML protocol binding to be used when returning the <Response>
// message. OneLogin Toolkit supports the HTTP-Redirect binding
// only for this endpoint.
Expand Down
1 change: 0 additions & 1 deletion lib/Saml2/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ public function getSLOurl()
*/
public function getSLOResponseUrl()
{
$url = null;
$idpData = $this->_settings->getIdPData();
if (isset($idpData['singleLogoutService']) && isset($idpData['singleLogoutService']['responseUrl'])) {
return $idpData['singleLogoutService']['responseUrl'];
Expand Down
3 changes: 3 additions & 0 deletions settings_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
'singleLogoutService' => array (
// URL Location of the IdP where the SP will send the SLO Request
'url' => '',
// URL location of the IdP where the SP will send the SLO Response (ResponseLocation)
// if not set, url for the SLO Request will be used
'responseUrl' => '',
// SAML protocol binding to be used when returning the <Response>
// message. Onelogin Toolkit supports for this endpoint the
// HTTP-Redirect binding only
Expand Down
1 change: 1 addition & 0 deletions tests/settings/settings1.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
),
'singleLogoutService' => array (
'url' => 'http://idp.example.com/SingleLogoutService.php',
'responseUrl' => 'http://idp.example.com/SingleLogoutServiceResponse.php',
),
'x509cert' => 'MIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYDVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4MTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xiZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2ZlaWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5vMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LONoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHISKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8BUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2QarQ4/67OZfHd7R+POBXhophSMv1ZOo',
),
Expand Down
27 changes: 19 additions & 8 deletions tests/src/OneLogin/Saml2/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ public function testGetSLOurl()
$this->assertEquals($this->_auth->getSLOurl(), $sloUrl);
}

/**
* Tests the getSLOResponseUrl method of the OneLogin_Saml2_Auth class
*
* @covers OneLogin_Saml2_Auth::getSLOurl
*/
public function testGetSLOResponseUrl()
{
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
$this->assertEquals($this->_auth->getSLOResponseUrl(), $sloResponseUrl);
}

/**
* Tests the processResponse method of the OneLogin_Saml2_Auth class
* Case No Response, An exception is throw
Expand Down Expand Up @@ -548,8 +559,8 @@ public function testProcessSLORequestInvalidValid()
$parsedQuery = getParamsFromUrl($targetUrl);

$this->assertEmpty($this->_auth->getErrors());
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
$this->assertContains($sloUrl, $targetUrl);
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
$this->assertContains($sloResponseUrl, $targetUrl);
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
}
Expand All @@ -570,8 +581,8 @@ public function testProcessSLORequestInvalidValid()
$parsedQuery = getParamsFromUrl($targetUrl);

$this->assertEmpty($this->_auth->getErrors());
$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
$this->assertContains($sloUrl, $targetUrl);
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
$this->assertContains($sloResponseUrl, $targetUrl);
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
$this->assertArrayNotHasKey('RelayState', $parsedQuery);
}
Expand Down Expand Up @@ -636,8 +647,8 @@ public function testProcessSLORequestDeletingSession()
$targetUrl = getUrlFromRedirect($trace);
$parsedQuery = getParamsFromUrl($targetUrl);

$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
$this->assertContains($sloUrl, $targetUrl);
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
$this->assertContains($sloResponseUrl, $targetUrl);
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
$this->assertArrayNotHasKey('RelayState', $parsedQuery);

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

$sloUrl = $this->_settingsInfo['idp']['singleLogoutService']['url'];
$this->assertContains($sloUrl, $targetUrl);
$sloResponseUrl = $this->_settingsInfo['idp']['singleLogoutService']['responseUrl'];
$this->assertContains($sloResponseUrl, $targetUrl);
$this->assertArrayHasKey('SAMLResponse', $parsedQuery);
$this->assertArrayNotHasKey('RelayState', $parsedQuery);

Expand Down
2 changes: 2 additions & 0 deletions tests/src/OneLogin/Saml2/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public function testCheckSettings()
$settingsInfo['idp']['entityID'] = 'entityId';
$settingsInfo['idp']['singleSignOnService']['url'] = 'invalid_value';
$settingsInfo['idp']['singleLogoutService']['url'] = 'invalid_value';
$settingsInfo['idp']['singleLogoutService']['responseUrl'] = 'invalid_value';
$settingsInfo['sp']['assertionConsumerService']['url'] = 'invalid_value';
$settingsInfo['sp']['singleLogoutService']['url'] = 'invalid_value';
try {
Expand All @@ -341,6 +342,7 @@ public function testCheckSettings()
} catch (OneLogin_Saml2_error $e) {
$this->assertContains('idp_sso_url_invalid', $e->getMessage());
$this->assertContains('idp_slo_url_invalid', $e->getMessage());
$this->assertContains('idp_slo_response_url_invalid', $e->getMessage());
$this->assertContains('sp_acs_url_invalid', $e->getMessage());
$this->assertContains('sp_sls_url_invalid', $e->getMessage());
}
Expand Down

0 comments on commit ecc1abc

Please sign in to comment.