Skip to content

Commit c43d61b

Browse files
committed
Add more tests to cover spValidationOnly param
1 parent 4bf537c commit c43d61b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

tests/src/OneLogin/Saml2/AuthTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ public function testGetSettings()
5252
$this->assertEquals($authSettings, $settings);
5353
}
5454

55+
/**
56+
* Tests the use of the spValidationOnly at OneLogin\Saml2\Auth
57+
*
58+
* @covers OneLogin\Saml2\Auth
59+
*/
60+
public function testSpValidateOnly()
61+
{
62+
$settingsDir = TEST_ROOT .'/settings/';
63+
include $settingsDir.'settings2.php';
64+
unset($settingsInfo['idp']);
65+
66+
$auth = new Auth($settingsInfo, true);
67+
$this->assertEmpty($auth->getErrors());
68+
69+
try {
70+
$auth2 = new Auth($settingsInfo, false);
71+
$this->fail('Error was not raised');
72+
} catch (Error $e) {
73+
$this->assertStringContainsString('idp_not_found', $e->getMessage());
74+
}
75+
76+
try {
77+
$auth3 = new Auth($settingsInfo);
78+
$this->fail('Error was not raised');
79+
} catch (Error $e) {
80+
$this->assertStringContainsString('idp_not_found', $e->getMessage());
81+
}
82+
}
83+
5584
/**
5685
* Tests the getLastRequestID method of the Auth class
5786
*

tests/src/OneLogin/Saml2/SettingsTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@ public function testLoadSettingsFromFile()
6464
$this->assertEmpty($settings->getErrors());
6565
}
6666

67+
/**
68+
* Tests the use of the spValidationOnly at OneLogin\Saml2\Settings
69+
*
70+
* @covers OneLogin\Saml2\Settings
71+
*/
72+
public function testSpValidateOnly()
73+
{
74+
$settingsDir = TEST_ROOT .'/settings/';
75+
include $settingsDir.'settings2.php';
76+
unset($settingsInfo['idp']);
77+
78+
$settings = new Settings($settingsInfo, true);
79+
$this->assertEmpty($settings->getErrors());
80+
81+
try {
82+
$settings2 = new Settings($settingsInfo, false);
83+
$this->fail('Error was not raised');
84+
} catch (Error $e) {
85+
$this->assertStringContainsString('idp_not_found', $e->getMessage());
86+
}
87+
88+
try {
89+
$settings3 = new Settings($settingsInfo);
90+
$this->fail('Error was not raised');
91+
} catch (Error $e) {
92+
$this->assertStringContainsString('idp_not_found', $e->getMessage());
93+
}
94+
}
95+
6796
/**
6897
* Tests getCertPath method of the Settings
6998
*

0 commit comments

Comments
 (0)