Skip to content

Commit 655a3cf

Browse files
Zhangqi ChenchenSir
authored andcommitted
Make Saml2\Auth can accept a param $spValidationOnly
The user who uses this package can decide if they want to make `$spValidationOnly` to be true
1 parent d074a81 commit 655a3cf

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Saml2/Auth.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ class OneLogin_Saml2_Auth
144144
* Initializes the SP SAML instance.
145145
*
146146
* @param array|object|null $oldSettings Setting data (You can provide a OneLogin_Saml_Settings, the settings object of the Saml folder implementation)
147+
* @param bool $spValidationOnly if you only as an SP , you should set it to false if not you should set it to true
147148
*
148149
* @throws OneLogin_Saml2_Error
149150
*/
150-
public function __construct($oldSettings = null)
151+
public function __construct($oldSettings = null , $spValidationOnly = true)
151152
{
152-
$this->_settings = new OneLogin_Saml2_Settings($oldSettings);
153+
$this->_settings = new OneLogin_Saml2_Settings($oldSettings, $spValidationOnly);
153154
}
154155

155156
/**

tests/src/OneLogin/Saml2/SettingsTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,4 +1164,17 @@ public function testIsDebugActive()
11641164
$settings3 = new OneLogin_Saml2_Settings($settingsInfo);
11651165
$this->assertTrue($settings3->isDebugActive());
11661166
}
1167+
/**
1168+
* Tests the checkSettings method of the OneLogin_Saml2_Settings
1169+
*
1170+
* @covers OneLogin_Saml2_Settings::checkSettings
1171+
*/
1172+
public function testSpValidateOnlyIsTrue()
1173+
{
1174+
$settingsDir = TEST_ROOT .'/settings/';
1175+
include $settingsDir.'settings2.php';
1176+
unset($settingsInfo['idp']);
1177+
$settings = new OneLogin_Saml2_Settings($settingsInfo,true);
1178+
$this->assertEmpty($settings->getErrors());
1179+
}
11671180
}

0 commit comments

Comments
 (0)