Skip to content

Commit

Permalink
Add more tests to cover spValidationOnly param
Browse files Browse the repository at this point in the history
  • Loading branch information
pitbulk committed May 30, 2024
1 parent 4bf537c commit c43d61b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/OneLogin/Saml2/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ public function testGetSettings()
$this->assertEquals($authSettings, $settings);
}

/**
* Tests the use of the spValidationOnly at OneLogin\Saml2\Auth
*
* @covers OneLogin\Saml2\Auth
*/
public function testSpValidateOnly()
{
$settingsDir = TEST_ROOT .'/settings/';
include $settingsDir.'settings2.php';
unset($settingsInfo['idp']);

$auth = new Auth($settingsInfo, true);
$this->assertEmpty($auth->getErrors());

try {
$auth2 = new Auth($settingsInfo, false);
$this->fail('Error was not raised');
} catch (Error $e) {
$this->assertStringContainsString('idp_not_found', $e->getMessage());
}

try {
$auth3 = new Auth($settingsInfo);
$this->fail('Error was not raised');
} catch (Error $e) {
$this->assertStringContainsString('idp_not_found', $e->getMessage());
}
}

/**
* Tests the getLastRequestID method of the Auth class
*
Expand Down
29 changes: 29 additions & 0 deletions tests/src/OneLogin/Saml2/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ public function testLoadSettingsFromFile()
$this->assertEmpty($settings->getErrors());
}

/**
* Tests the use of the spValidationOnly at OneLogin\Saml2\Settings
*
* @covers OneLogin\Saml2\Settings
*/
public function testSpValidateOnly()
{
$settingsDir = TEST_ROOT .'/settings/';
include $settingsDir.'settings2.php';
unset($settingsInfo['idp']);

$settings = new Settings($settingsInfo, true);
$this->assertEmpty($settings->getErrors());

try {
$settings2 = new Settings($settingsInfo, false);
$this->fail('Error was not raised');
} catch (Error $e) {
$this->assertStringContainsString('idp_not_found', $e->getMessage());
}

try {
$settings3 = new Settings($settingsInfo);
$this->fail('Error was not raised');
} catch (Error $e) {
$this->assertStringContainsString('idp_not_found', $e->getMessage());
}
}

/**
* Tests getCertPath method of the Settings
*
Expand Down

0 comments on commit c43d61b

Please sign in to comment.