|
|
|
@ -78,55 +78,52 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertTrue($expected === $access->escapeFilterPart($input));
|
|
|
|
$this->assertTrue($expected === $access->escapeFilterPart($input));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testConvertSID2StrSuccess() {
|
|
|
|
/** @dataProvider convertSID2StrSuccessData */
|
|
|
|
|
|
|
|
public function testConvertSID2StrSuccess(array $sidArray, $sidExpected) {
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
|
|
|
|
|
|
|
|
if(!function_exists('\bcadd')) {
|
|
|
|
$sidBinary = implode('', $sidArray);
|
|
|
|
$this->markTestSkipped('bcmath not available');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sidBinary = file_get_contents(__DIR__ . '/data/sid.dat');
|
|
|
|
|
|
|
|
$sidExpected = 'S-1-5-21-249921958-728525901-1594176202';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame($sidExpected, $access->convertSID2Str($sidBinary));
|
|
|
|
$this->assertSame($sidExpected, $access->convertSID2Str($sidBinary));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function convertSID2StrSuccessData() {
|
|
|
|
|
|
|
|
return array(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
"\x01",
|
|
|
|
|
|
|
|
"\x04",
|
|
|
|
|
|
|
|
"\x00\x00\x00\x00\x00\x05",
|
|
|
|
|
|
|
|
"\x15\x00\x00\x00",
|
|
|
|
|
|
|
|
"\xa6\x81\xe5\x0e",
|
|
|
|
|
|
|
|
"\x4d\x6c\x6c\x2b",
|
|
|
|
|
|
|
|
"\xca\x32\x05\x5f",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
'S-1-5-21-249921958-728525901-1594176202',
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
"\x01",
|
|
|
|
|
|
|
|
"\x02",
|
|
|
|
|
|
|
|
"\xFF\xFF\xFF\xFF\xFF\xFF",
|
|
|
|
|
|
|
|
"\xFF\xFF\xFF\xFF",
|
|
|
|
|
|
|
|
"\xFF\xFF\xFF\xFF",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
'S-1-281474976710655-4294967295-4294967295',
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testConvertSID2StrInputError() {
|
|
|
|
public function testConvertSID2StrInputError() {
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
|
|
|
|
|
|
|
|
if(!function_exists('\bcadd')) {
|
|
|
|
|
|
|
|
$this->markTestSkipped('bcmath not available');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sidIllegal = 'foobar';
|
|
|
|
$sidIllegal = 'foobar';
|
|
|
|
$sidExpected = '';
|
|
|
|
$sidExpected = '';
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame($sidExpected, $access->convertSID2Str($sidIllegal));
|
|
|
|
$this->assertSame($sidExpected, $access->convertSID2Str($sidIllegal));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testConvertSID2StrNoBCMath() {
|
|
|
|
|
|
|
|
if(function_exists('\bcadd')) {
|
|
|
|
|
|
|
|
$removed = false;
|
|
|
|
|
|
|
|
if(function_exists('runkit_function_remove')) {
|
|
|
|
|
|
|
|
$removed = !runkit_function_remove('\bcadd');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$removed) {
|
|
|
|
|
|
|
|
$this->markTestSkipped('bcadd could not be removed for ' .
|
|
|
|
|
|
|
|
'testing without bcmath');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sidBinary = file_get_contents(__DIR__ . '/data/sid.dat');
|
|
|
|
|
|
|
|
$sidExpected = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame($sidExpected, $access->convertSID2Str($sidBinary));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetDomainDNFromDNSuccess() {
|
|
|
|
public function testGetDomainDNFromDNSuccess() {
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
list($lw, $con, $um) = $this->getConnecterAndLdapMock();
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
$access = new Access($con, $lw, $um);
|
|
|
|
|