Skip to content

Commit

Permalink
make the SSO config could decide if should to set the IDP settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
BadJacky committed Jul 12, 2022
1 parent 6f40da4 commit b0f1f4a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php-versions: [7.3, 7.4, 8.0]
php-versions: [7.3, 7.4, 8.0, 8.1]
steps:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
Expand Down
5 changes: 3 additions & 2 deletions src/Saml2/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ class Auth
* Initializes the SP SAML instance.
*
* @param array|null $settings Setting data
* @param bool $spValidationOnly if true, The library will only validate the SAML SP settings,
*
* @throws Exception
* @throws Error
*/
public function __construct(array $settings = null)
public function __construct(array $settings = null, bool $spValidationOnly = false)
{
$this->_settings = new Settings($settings);
$this->_settings = new Settings($settings, $spValidationOnly);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Saml2/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Settings
* @throws Error If any settings parameter is invalid
* @throws Exception If Settings is incorrectly supplied
*/
public function __construct(array $settings = null, $spValidationOnly = false)
public function __construct(array $settings = null,bool $spValidationOnly = false)
{
$this->_spValidationOnly = $spValidationOnly;
$this->_loadPaths();
Expand Down
31 changes: 31 additions & 0 deletions tests/src/OneLogin/Saml2/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1578,4 +1578,35 @@ public function testGetIdFromLastLogoutResponse()
$this->_auth->processSLO(false, null, false, null, true);
$this->assertEquals('_f9ee61bd9dbf63606faa9ae3b10548d5b3656fb859', $this->_auth->getLastMessageId());
}

/**
* Tests the checkSettings method of the OneLogin_Saml2_Settings when SpValidateOnly is false and IdP is not defined
*
* @covers OneLogin_Saml2_Settings::checkSettings
*/
public function testSpValidateOnlyIsTrue()
{
$settingsDir = TEST_ROOT . '/settings/';
include $settingsDir . 'settings2.php';
unset($settingsInfo['idp']);
$settings = new Settings($settingsInfo, true);
$this->assertEmpty($settings->getErrors());
}

/**
* Tests the checkSettings method of the OneLogin_Saml2_Settings when SpValidateOnly is false and IdP is not defined
*
* @covers OneLogin_Saml2_Settings::checkSettings
*/
public function testSpValidateOnlyIsFalse()
{
$settingsDir = TEST_ROOT . '/settings/';
include $settingsDir . 'settings2.php';
unset($settingsInfo['idp']);
try {
$settings = new Settings($settingsInfo);
} catch (Error $e) {
$this->assertContains('idp_not_found', $e->getMessage());
}
}
}

0 comments on commit b0f1f4a

Please sign in to comment.