diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-09-21 11:47:00 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-09-21 13:32:42 +0200 |
commit | 71781941984b75e12366fe87bb3d2f92f3dbf2ff (patch) | |
tree | b719bfdc0fa9728d52bb2052e0f9ba836b426ad0 /apps/user_ldap/tests | |
parent | dbf7905149222115a2cd0334efcf8c93afa8683e (diff) | |
download | nextcloud-server-71781941984b75e12366fe87bb3d2f92f3dbf2ff.tar.gz nextcloud-server-71781941984b75e12366fe87bb3d2f92f3dbf2ff.zip |
fix caching of objectsid searches
- store result when no name could be retrieved, too
- cached value is not an array, was treated wrongly
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r-- | apps/user_ldap/tests/Group_LDAPTest.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index acb6ad3d710..cb637dcc108 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -320,6 +320,38 @@ class Group_LDAPTest extends TestCase { $this->assertSame(false, $gid); } + public function testPrimaryGroupID2NameSuccessCache() { + $access = $this->getAccessMock(); + $pluginManager = $this->getPluginManagerMock(); + + $this->enableGroups($access); + + $userDN = 'cn=alice,cn=foo,dc=barfoo,dc=bar'; + $gid = '3117'; + $groupDN = 'cn=foo,dc=barfoo,dc=bar'; + + /** @var MockObject $connection */ + $connection = $access->connection; + $connection->expects($this->once()) + ->method('getFromCache') + ->with('primaryGroupIDtoName_' . $gid) + ->willReturn('MyGroup'); + + $access->expects($this->never()) + ->method('getSID'); + + $access->expects($this->never()) + ->method('searchGroups'); + + $access->expects($this->never()) + ->method('dn2groupname'); + + $groupBackend = new GroupLDAP($access, $pluginManager); + $group = $groupBackend->primaryGroupID2Name($gid, $userDN); + + $this->assertSame('MyGroup', $group); + } + public function testPrimaryGroupID2NameSuccess() { $access = $this->getAccessMock(); $pluginManager = $this->getPluginManagerMock(); |