diff options
author | blizzz <blizzz@owncloud.com> | 2014-11-03 14:03:26 +0100 |
---|---|---|
committer | blizzz <blizzz@owncloud.com> | 2014-11-03 14:03:26 +0100 |
commit | dc9ea893fd89bcabce922ba626c6953cd5a1fbef (patch) | |
tree | e0e4717cdf9dfc17f35d8a3e1e00694e6426013f /apps/user_ldap/tests | |
parent | 79b650a0238089a935073c1ebe7e33fd7a0c52a4 (diff) | |
parent | d1410b46a9822aefc6547db95add1c1f7fa1f617 (diff) | |
download | nextcloud-server-dc9ea893fd89bcabce922ba626c6953cd5a1fbef.tar.gz nextcloud-server-dc9ea893fd89bcabce922ba626c6953cd5a1fbef.zip |
Merge pull request #11172 from owncloud/user-ldap-no-bcmath
Fix ldap convertSID2Str() / Remove BCMath dependency
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r-- | apps/user_ldap/tests/access.php | 63 | ||||
-rw-r--r-- | apps/user_ldap/tests/data/sid.dat | bin | 24 -> 0 bytes |
2 files changed, 30 insertions, 33 deletions
diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php index f436784675d..8ff39800808 100644 --- a/apps/user_ldap/tests/access.php +++ b/apps/user_ldap/tests/access.php @@ -78,55 +78,52 @@ class Test_Access extends \PHPUnit_Framework_TestCase { $this->assertTrue($expected === $access->escapeFilterPart($input)); } - public function testConvertSID2StrSuccess() { + /** @dataProvider convertSID2StrSuccessData */ + public function testConvertSID2StrSuccess(array $sidArray, $sidExpected) { list($lw, $con, $um) = $this->getConnecterAndLdapMock(); $access = new Access($con, $lw, $um); - if(!function_exists('\bcadd')) { - $this->markTestSkipped('bcmath not available'); - } - - $sidBinary = file_get_contents(__DIR__ . '/data/sid.dat'); - $sidExpected = 'S-1-5-21-249921958-728525901-1594176202'; - + $sidBinary = implode('', $sidArray); $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() { list($lw, $con, $um) = $this->getConnecterAndLdapMock(); $access = new Access($con, $lw, $um); - if(!function_exists('\bcadd')) { - $this->markTestSkipped('bcmath not available'); - } - $sidIllegal = 'foobar'; $sidExpected = ''; $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() { list($lw, $con, $um) = $this->getConnecterAndLdapMock(); $access = new Access($con, $lw, $um); diff --git a/apps/user_ldap/tests/data/sid.dat b/apps/user_ldap/tests/data/sid.dat Binary files differdeleted file mode 100644 index 3d500c6a872..00000000000 --- a/apps/user_ldap/tests/data/sid.dat +++ /dev/null |