|
|
|
|
@ -22,6 +22,9 @@ use OCA\Encryption; |
|
|
|
|
class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { |
|
|
|
|
|
|
|
|
|
const TEST_ENCRYPTION_UTIL_USER1 = "test-util-user1"; |
|
|
|
|
const TEST_ENCRYPTION_UTIL_USER2 = "test-util-user2"; |
|
|
|
|
const TEST_ENCRYPTION_UTIL_GROUP1 = "test-util-group1"; |
|
|
|
|
const TEST_ENCRYPTION_UTIL_GROUP2 = "test-util-group2"; |
|
|
|
|
const TEST_ENCRYPTION_UTIL_LEGACY_USER = "test-legacy-user"; |
|
|
|
|
|
|
|
|
|
public $userId; |
|
|
|
|
@ -59,7 +62,15 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { |
|
|
|
|
|
|
|
|
|
// create test user |
|
|
|
|
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true); |
|
|
|
|
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true); |
|
|
|
|
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true); |
|
|
|
|
|
|
|
|
|
// create groups |
|
|
|
|
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1); |
|
|
|
|
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2); |
|
|
|
|
|
|
|
|
|
// add user 1 to group1 |
|
|
|
|
\OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,7 +127,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { |
|
|
|
|
public static function tearDownAfterClass() { |
|
|
|
|
// cleanup test user |
|
|
|
|
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); |
|
|
|
|
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2); |
|
|
|
|
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); |
|
|
|
|
//cleanup groups |
|
|
|
|
\OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP1); |
|
|
|
|
\OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -457,6 +472,31 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @dataProvider dataProviderFortestIsMountPointApplicableToUser |
|
|
|
|
*/ |
|
|
|
|
function testIsMountPointApplicableToUser($mount, $expectedResult) { |
|
|
|
|
self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1); |
|
|
|
|
$dummyClass = new DummyUtilClass($this->view, self::TEST_ENCRYPTION_UTIL_USER1); |
|
|
|
|
$result = $dummyClass->testIsMountPointApplicableToUser($mount); |
|
|
|
|
|
|
|
|
|
$this->assertSame($expectedResult, $result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function dataProviderFortestIsMountPointApplicableToUser() { |
|
|
|
|
return array( |
|
|
|
|
array(array('applicable' => array('groups' => array(), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER1))), true), |
|
|
|
|
array(array('applicable' => array('groups' => array(), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), false), |
|
|
|
|
array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP1), 'users' => array())), true), |
|
|
|
|
array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP1), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), true), |
|
|
|
|
array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2))), false), |
|
|
|
|
array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array(self::TEST_ENCRYPTION_UTIL_USER2, 'all'))), true), |
|
|
|
|
array(array('applicable' => array('groups' => array(self::TEST_ENCRYPTION_UTIL_GROUP2), 'users' => array('all'))), true), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $user |
|
|
|
|
* @param bool $create |
|
|
|
|
@ -507,3 +547,12 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* dummy class extends \OCA\Encryption\Util to access protected methods for testing |
|
|
|
|
*/ |
|
|
|
|
class DummyUtilClass extends \OCA\Encryption\Util { |
|
|
|
|
public function testIsMountPointApplicableToUser($mount) { |
|
|
|
|
return $this->isMountPointApplicableToUser($mount); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|