Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-06-09 13:03:03 +0300
committerGitHub <noreply@github.com>2022-06-09 13:03:03 +0300
commit254cb7ad0cb2ebf31ca3124c48ef3de2b6e45e56 (patch)
tree3e6d13b01772e71c3914d8cf7dc723a1d23c3b38 /tests/lib
parent7e819852ee436b4d3f4b10e46fcc46a8d1d25111 (diff)
parent887aa58905d5052f552cbf9a25dfa250b7513662 (diff)
Merge pull request #32770 from nextcloud/backport/32697/stable24
[stable24] Fix get avatar authorization
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php33
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index ce6981a2a21..ae9c0e1671f 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -161,6 +161,10 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUID')
->willReturn('valid-user');
+ $this->userSession->expects($this->once())
+ ->method('getUser')
+ ->willReturn($user);
+
$folder = $this->createMock(ISimpleFolder::class);
$this->appData
->expects($this->once())
@@ -168,26 +172,45 @@ class AvatarManagerTest extends \Test\TestCase {
->with('valid-user')
->willReturn($folder);
+ $account = $this->createMock(IAccount::class);
+ $this->accountManager->expects($this->once())
+ ->method('getAccount')
+ ->with($user)
+ ->willReturn($account);
+
+ $property = $this->createMock(IAccountProperty::class);
+ $account->expects($this->once())
+ ->method('getProperty')
+ ->with(IAccountManager::PROPERTY_AVATAR)
+ ->willReturn($property);
+
+ $property->expects($this->once())
+ ->method('getScope')
+ ->willReturn(IAccountManager::SCOPE_FEDERATED);
+
$expected = new UserAvatar($folder, $this->l10n, $user, $this->logger, $this->config);
$this->assertEquals($expected, $this->avatarManager->getAvatar('vaLid-USER'));
}
- public function knownUnknownProvider() {
+ public function dataGetAvatarScopes() {
return [
- [IAccountManager::SCOPE_LOCAL, false, false, false],
- [IAccountManager::SCOPE_LOCAL, true, false, false],
-
// public access cannot see real avatar
[IAccountManager::SCOPE_PRIVATE, true, false, true],
// unknown users cannot see real avatar
[IAccountManager::SCOPE_PRIVATE, false, false, true],
// known users can see real avatar
[IAccountManager::SCOPE_PRIVATE, false, true, false],
+ [IAccountManager::SCOPE_LOCAL, false, false, false],
+ [IAccountManager::SCOPE_LOCAL, true, false, false],
+ [IAccountManager::SCOPE_FEDERATED, false, false, false],
+ [IAccountManager::SCOPE_FEDERATED, true, false, false],
+ [IAccountManager::SCOPE_PUBLISHED, false, false, false],
+ [IAccountManager::SCOPE_PUBLISHED, true, false, false],
];
}
/**
- * @dataProvider knownUnknownProvider
+ * @dataProvider dataGetAvatarScopes
*/
public function testGetAvatarScopes($avatarScope, $isPublicCall, $isKnownUser, $expectedPlaceholder) {
if ($isPublicCall) {