[Pkg-owncloud-commits] [owncloud] 05/23: Backport #9576
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 15:21:35 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit acf80ba7cc936b32ea5183311d0e7db4838d3705
Author: Arthur Schiwon <blizzz at owncloud.com>
Date: Thu Jul 10 20:43:00 2014 +0200
Backport #9576
warn and continue gracefully if bcmath is not installed
make tests deal with missing bcmath
---
apps/user_ldap/lib/access.php | 6 ++++++
apps/user_ldap/tests/access.php | 29 +++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index e3b6566..23ba425 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -1298,6 +1298,12 @@ class Access extends LDAPUtility implements user\IUserTools {
*/
public function convertSID2Str($sid) {
try {
+ if(!function_exists('bcadd')) {
+ \OCP\Util::writeLog('user_ldap',
+ 'You need to install bcmath module for PHP to have support ' .
+ 'for AD primary groups', \OCP\Util::WARN);
+ throw new \Exception('missing bcmath module');
+ }
$srl = ord($sid[0]);
$numberSubID = ord($sid[1]);
$x = substr($sid, 2, 6);
diff --git a/apps/user_ldap/tests/access.php b/apps/user_ldap/tests/access.php
index 2ff7540..e77aad7 100644
--- a/apps/user_ldap/tests/access.php
+++ b/apps/user_ldap/tests/access.php
@@ -82,6 +82,10 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
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';
@@ -92,12 +96,37 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list