1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Modules\Monitor\Test; |
4
|
|
|
|
5
|
|
|
use \SimpleSAML_Configuration as ApplicationConfiguration; |
6
|
|
|
use \SimpleSAML\Modules\Monitor\TestCase as TestCase; |
7
|
|
|
use \SimpleSAML\Modules\Monitor\TestData as TestData; |
8
|
|
|
use \SimpleSAML\Modules\Monitor\State as State; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Tests for TestCase\Ldap\Search |
12
|
|
|
*/ |
13
|
|
|
class TestLdapSearchTest extends \PHPUnit_Framework_TestCase |
14
|
|
|
{ |
15
|
|
|
public function testSearchSuccesful() |
16
|
|
|
{ |
17
|
|
|
$authSourceData = [ |
18
|
|
|
'search.base' => 'OU=example,DC=example,DC=org', |
19
|
|
|
'search.username' => 'testuser', |
20
|
|
|
'search.password' => 'password', |
21
|
|
|
]; |
22
|
|
|
$connectionMock = $this->getMock('LdapSearch', array('searchfordn')); |
23
|
|
|
$connectionMock->expects($this->once())->method('searchfordn')->will($this->returnValue(true)); |
24
|
|
|
$confTest = new TestCase\AuthSource\Ldap\Search( |
25
|
|
|
new TestData([ |
26
|
|
|
'authSourceData' => ApplicationConfiguration::loadFromArray($authSourceData), |
27
|
|
|
'connection' => $connectionMock, |
28
|
|
|
]) |
29
|
|
|
); |
30
|
|
|
$testResult = $confTest->getTestResult(); |
31
|
|
|
|
32
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testSearchFailed() |
36
|
|
|
{ |
37
|
|
|
$authSourceData = [ |
38
|
|
|
'search.base' => 'OU=example,DC=example,DC=org', |
39
|
|
|
'search.username' => 'CN=testuser,OU=example,DC=example,DC=org', |
40
|
|
|
'search.password' => 'password', |
41
|
|
|
]; |
42
|
|
|
$connectionMock = $this->getMock('LdapSearch', array('searchfordn')); |
43
|
|
|
$connectionMock->expects($this->once())->method('searchfordn')->will($this->throwException(new \SimpleSAML_Error_Error('UNHANDLEDEXCEPTION'))); |
44
|
|
|
$confTest = new TestCase\AuthSource\Ldap\Search( |
45
|
|
|
new TestData([ |
46
|
|
|
'authSourceData' => ApplicationConfiguration::loadFromArray($authSourceData), |
47
|
|
|
'connection' => $connectionMock, |
48
|
|
|
]) |
49
|
|
|
); |
50
|
|
|
$testResult = $confTest->getTestResult(); |
51
|
|
|
|
52
|
|
|
$this->assertEquals(State::ERROR, $testResult->getState()); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths