diff options
Diffstat (limited to 'apps/user_ldap/tests/access.php')
-rw-r--r-- | apps/user_ldap/tests/access.php | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index 8ead5d68482..2ff7540b8ef 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -77,4 +77,54 @@ class Test_Access extends \PHPUnit_Framework_TestCase { $expected = 'foo\\\\*bar'; $this->assertTrue($expected === $access->escapeFilterPart($input)); } -}
\ No newline at end of file + + public function testConvertSID2StrSuccess() { + list($lw, $con, $um) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw, $um); + + $sidBinary = file_get_contents(__DIR__ . '/data/sid.dat'); + $sidExpected = 'S-1-5-21-249921958-728525901-1594176202'; + + $this->assertSame($sidExpected, $access->convertSID2Str($sidBinary)); + } + + public function testConvertSID2StrInputError() { + list($lw, $con, $um) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw, $um); + + $sidIllegal = 'foobar'; + $sidExpected = ''; + + $this->assertSame($sidExpected, $access->convertSID2Str($sidIllegal)); + } + + public function testGetDomainDNFromDNSuccess() { + list($lw, $con, $um) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw, $um); + + $inputDN = 'uid=zaphod,cn=foobar,dc=my,dc=server,dc=com'; + $domainDN = 'dc=my,dc=server,dc=com'; + + $lw->expects($this->once()) + ->method('explodeDN') + ->with($inputDN, 0) + ->will($this->returnValue(explode(',', $inputDN))); + + $this->assertSame($domainDN, $access->getDomainDNFromDN($inputDN)); + } + + public function testGetDomainDNFromDNError() { + list($lw, $con, $um) = $this->getConnecterAndLdapMock(); + $access = new Access($con, $lw, $um); + + $inputDN = 'foobar'; + $expected = ''; + + $lw->expects($this->once()) + ->method('explodeDN') + ->with($inputDN, 0) + ->will($this->returnValue(false)); + + $this->assertSame($expected, $access->getDomainDNFromDN($inputDN)); + } +} |