diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-07-03 00:38:25 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-07-03 01:45:07 +0200 |
commit | a4dda465c215042c84ee5954fec3a8f7203de5e2 (patch) | |
tree | ab3c7764fe03affc90c78802abb8691a827231c6 /apps/user_ldap/tests/User_LDAPTest.php | |
parent | 552da85df880e921c11a4bfd88d49136e104fdf5 (diff) | |
download | nextcloud-server-a4dda465c215042c84ee5954fec3a8f7203de5e2.tar.gz nextcloud-server-a4dda465c215042c84ee5954fec3a8f7203de5e2.zip |
let user set avatar in nextcloud von LDAP provides invalid image data
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests/User_LDAPTest.php')
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 8def34045ec..927a7550f60 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -1312,6 +1312,34 @@ class User_LDAPTest extends TestCase { $this->assertEquals($this->backend->setPassword('uid', 'password'),'result'); } + public function avatarDataProvider() { + return [ + [ 'validImageData', false ], + [ 'corruptImageData', true ], + [ false, true] + ]; + } + + /** @dataProvider avatarDataProvider */ + public function testCanChangeAvatar($imageData, $expected) { + $isValidImage = strpos((string)$imageData, 'valid') === 0; + + $user = $this->createMock(User::class); + $user->expects($this->once()) + ->method('getAvatarImage') + ->willReturn($imageData); + $user->expects($this->atMost(1)) + ->method('updateAvatar') + ->willReturn($isValidImage); + + $this->userManager->expects($this->atLeastOnce()) + ->method('get') + ->willReturn($user); + + /** @noinspection PhpUnhandledExceptionInspection */ + $this->assertSame($expected, $this->backend->canChangeAvatar('uid')); + } + public function testCanChangeAvatarWithPlugin() { $this->pluginManager->expects($this->once()) ->method('implementsActions') |