summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-10-16 16:08:59 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-10-17 20:16:04 +0200
commite16122f2a1da89b95101808e9f32cea8f267a2d4 (patch)
treeffdfa00b3d2646af62a6d418dfa160c15b55433b
parent4e8c7570d40fd8862b3b45b08d21bc1967779f01 (diff)
downloadnextcloud-server-e16122f2a1da89b95101808e9f32cea8f267a2d4.tar.gz
nextcloud-server-e16122f2a1da89b95101808e9f32cea8f267a2d4.zip
add one simple cache test
-rw-r--r--apps/user_ldap/tests/group_ldap.php33
1 files changed, 29 insertions, 4 deletions
diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php
index c4aed25a1cc..d1262e4f5b8 100644
--- a/apps/user_ldap/tests/group_ldap.php
+++ b/apps/user_ldap/tests/group_ldap.php
@@ -59,10 +59,7 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase {
private function enableGroups($access) {
$access->connection->expects($this->any())
->method('__get')
- ->will($this->returnCallback(function($name) {
-// if($name === 'ldapLoginFilter') {
-// return '%uid';
-// }
+ ->will($this->returnCallback(function() {
return 1;
}));
}
@@ -269,4 +266,32 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase {
$this->assertSame(false, $gid);
}
+ /**
+ * tests whether Group Backend behaves correctly when cache with uid and gid
+ * is hit
+ */
+ public function testInGroupHitsUidGidCache() {
+ $access = $this->getAccessMock();
+ $this->enableGroups($access);
+
+ $uid = 'someUser';
+ $gid = 'someGroup';
+ $cacheKey = 'inGroup'.$uid.':'.$gid;
+ $access->connection->expects($this->once())
+ ->method('isCached')
+ ->with($cacheKey)
+ ->will($this->returnValue(true));
+
+ $access->connection->expects($this->once())
+ ->method('getFromCache')
+ ->with($cacheKey)
+ ->will($this->returnValue(true));
+
+ $access->expects($this->never())
+ ->method('username2dn');
+
+ $groupBackend = new GroupLDAP($access);
+ $groupBackend->inGroup($uid, $gid);
+ }
+
}