Skip to content

Commit a56ca27

Browse files
authored
Merge pull request #529 from zbcchen/4.x-dev
4.x dev
2 parents bc0eda0 + b0f1f4a commit a56ca27

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/php-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
operating-system: ['ubuntu-latest']
19-
php-versions: [7.3, 7.4, 8.0]
19+
php-versions: [7.3, 7.4, 8.0, 8.1]
2020
steps:
2121
- name: Setup PHP, with composer and extensions
2222
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php

src/Saml2/Auth.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@ class Auth
168168
* Initializes the SP SAML instance.
169169
*
170170
* @param array|null $settings Setting data
171+
* @param bool $spValidationOnly if true, The library will only validate the SAML SP settings,
171172
*
172173
* @throws Exception
173174
* @throws Error
174175
*/
175-
public function __construct(array $settings = null)
176+
public function __construct(array $settings = null, bool $spValidationOnly = false)
176177
{
177-
$this->_settings = new Settings($settings);
178+
$this->_settings = new Settings($settings, $spValidationOnly);
178179
}
179180

180181
/**

src/Saml2/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Settings
122122
* @throws Error If any settings parameter is invalid
123123
* @throws Exception If Settings is incorrectly supplied
124124
*/
125-
public function __construct(array $settings = null, $spValidationOnly = false)
125+
public function __construct(array $settings = null,bool $spValidationOnly = false)
126126
{
127127
$this->_spValidationOnly = $spValidationOnly;
128128
$this->_loadPaths();

tests/src/OneLogin/Saml2/AuthTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,4 +1578,35 @@ public function testGetIdFromLastLogoutResponse()
15781578
$this->_auth->processSLO(false, null, false, null, true);
15791579
$this->assertEquals('_f9ee61bd9dbf63606faa9ae3b10548d5b3656fb859', $this->_auth->getLastMessageId());
15801580
}
1581+
1582+
/**
1583+
* Tests the checkSettings method of the OneLogin_Saml2_Settings when SpValidateOnly is false and IdP is not defined
1584+
*
1585+
* @covers OneLogin_Saml2_Settings::checkSettings
1586+
*/
1587+
public function testSpValidateOnlyIsTrue()
1588+
{
1589+
$settingsDir = TEST_ROOT . '/settings/';
1590+
include $settingsDir . 'settings2.php';
1591+
unset($settingsInfo['idp']);
1592+
$settings = new Settings($settingsInfo, true);
1593+
$this->assertEmpty($settings->getErrors());
1594+
}
1595+
1596+
/**
1597+
* Tests the checkSettings method of the OneLogin_Saml2_Settings when SpValidateOnly is false and IdP is not defined
1598+
*
1599+
* @covers OneLogin_Saml2_Settings::checkSettings
1600+
*/
1601+
public function testSpValidateOnlyIsFalse()
1602+
{
1603+
$settingsDir = TEST_ROOT . '/settings/';
1604+
include $settingsDir . 'settings2.php';
1605+
unset($settingsInfo['idp']);
1606+
try {
1607+
$settings = new Settings($settingsInfo);
1608+
} catch (Error $e) {
1609+
$this->assertContains('idp_not_found', $e->getMessage());
1610+
}
1611+
}
15811612
}

0 commit comments

Comments
 (0)