Merge pull request #2761 from nextcloud/dont-resolve-shares-if-public-sharing-is-disabled

Don't resolve public share token if public sharing is disabled
This commit is contained in:
Björn Schießle 2016-12-22 11:57:05 +01:00 committed by GitHub
commit 3453f4e97c
2 changed files with 103 additions and 55 deletions

View File

@ -1055,8 +1055,10 @@ class Manager implements IManager {
public function getShareByToken($token) { public function getShareByToken($token) {
$share = null; $share = null;
try { try {
if($this->shareApiAllowLinks()) {
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
$share = $provider->getShareByToken($token); $share = $provider->getShareByToken($token);
}
} catch (ProviderException $e) { } catch (ProviderException $e) {
} catch (ShareNotFound $e) { } catch (ShareNotFound $e) {
} }
@ -1072,7 +1074,7 @@ class Manager implements IManager {
} }
} }
// If it is not a link share try to fetch a federated share by token // If it is not a link share try to fetch a mail share by token
if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
try { try {
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL); $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL);

View File

@ -61,25 +61,25 @@ class ManagerTest extends \Test\TestCase {
/** @var Manager */ /** @var Manager */
protected $manager; protected $manager;
/** @var ILogger */ /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
protected $logger; protected $logger;
/** @var IConfig */ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config; protected $config;
/** @var ISecureRandom */ /** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
protected $secureRandom; protected $secureRandom;
/** @var IHasher */ /** @var IHasher|\PHPUnit_Framework_MockObject_MockObject */
protected $hasher; protected $hasher;
/** @var IShareProvider|\PHPUnit_Framework_MockObject_MockObject */ /** @var IShareProvider|\PHPUnit_Framework_MockObject_MockObject */
protected $defaultProvider; protected $defaultProvider;
/** @var IMountManager */ /** @var IMountManager|\PHPUnit_Framework_MockObject_MockObject */
protected $mountManager; protected $mountManager;
/** @var IGroupManager */ /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager; protected $groupManager;
/** @var IL10N */ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
protected $l; protected $l;
/** @var DummyFactory */ /** @var DummyFactory */
protected $factory; protected $factory;
/** @var IUserManager */ /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
protected $userManager; protected $userManager;
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */ /** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
protected $rootFolder; protected $rootFolder;
@ -488,7 +488,7 @@ class ManagerTest extends \Test\TestCase {
->method('delete') ->method('delete')
->withConsecutive($child1, $child2, $child3); ->withConsecutive($child1, $child2, $child3);
$result = $this->invokePrivate($manager, 'deleteChildren', [$share]); $result = self::invokePrivate($manager, 'deleteChildren', [$share]);
$this->assertSame($shares, $result); $this->assertSame($shares, $result);
} }
@ -532,7 +532,7 @@ class ManagerTest extends \Test\TestCase {
} }
/** /**
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
* @expectedExceptionMessage Passwords are enforced for link shares * @expectedExceptionMessage Passwords are enforced for link shares
*/ */
public function testVerifyPasswordNullButEnforced() { public function testVerifyPasswordNullButEnforced() {
@ -540,7 +540,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'yes'], ['core', 'shareapi_enforce_links_password', 'no', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'verifyPassword', [null]); self::invokePrivate($this->manager, 'verifyPassword', [null]);
} }
public function testVerifyPasswordNull() { public function testVerifyPasswordNull() {
@ -548,7 +548,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'no'], ['core', 'shareapi_enforce_links_password', 'no', 'no'],
])); ]));
$result = $this->invokePrivate($this->manager, 'verifyPassword', [null]); $result = self::invokePrivate($this->manager, 'verifyPassword', [null]);
$this->assertNull($result); $this->assertNull($result);
} }
@ -564,12 +564,12 @@ class ManagerTest extends \Test\TestCase {
} }
); );
$result = $this->invokePrivate($this->manager, 'verifyPassword', ['password']); $result = self::invokePrivate($this->manager, 'verifyPassword', ['password']);
$this->assertNull($result); $this->assertNull($result);
} }
/** /**
* @expectedException Exception * @expectedException \Exception
* @expectedExceptionMessage password not accepted * @expectedExceptionMessage password not accepted
*/ */
public function testVerifyPasswordHookFails() { public function testVerifyPasswordHookFails() {
@ -585,7 +585,7 @@ class ManagerTest extends \Test\TestCase {
} }
); );
$this->invokePrivate($this->manager, 'verifyPassword', ['password']); self::invokePrivate($this->manager, 'verifyPassword', ['password']);
} }
public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner, public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
@ -699,6 +699,7 @@ class ManagerTest extends \Test\TestCase {
* *
* @param $share * @param $share
* @param $exceptionMessage * @param $exceptionMessage
* @param $exception
*/ */
public function testGeneralChecks($share, $exceptionMessage, $exception) { public function testGeneralChecks($share, $exceptionMessage, $exception) {
$thrown = null; $thrown = null;
@ -718,7 +719,7 @@ class ManagerTest extends \Test\TestCase {
try { try {
$this->invokePrivate($this->manager, 'generalCreateChecks', [$share]); self::invokePrivate($this->manager, 'generalCreateChecks', [$share]);
$thrown = false; $thrown = false;
} catch (\OCP\Share\Exceptions\GenericShareException $e) { } catch (\OCP\Share\Exceptions\GenericShareException $e) {
$this->assertEquals($exceptionMessage, $e->getHint()); $this->assertEquals($exceptionMessage, $e->getHint());
@ -754,7 +755,7 @@ class ManagerTest extends \Test\TestCase {
->setSharedBy('user1') ->setSharedBy('user1')
->setNode($userFolder); ->setNode($userFolder);
$this->invokePrivate($this->manager, 'generalCreateChecks', [$share]); self::invokePrivate($this->manager, 'generalCreateChecks', [$share]);
} }
/** /**
@ -770,11 +771,11 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($past); $share->setExpirationDate($past);
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} }
/** /**
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
* @expectedExceptionMessage Expiration date is enforced * @expectedExceptionMessage Expiration date is enforced
*/ */
public function testvalidateExpirationDateEnforceButNotSet() { public function testvalidateExpirationDateEnforceButNotSet() {
@ -787,7 +788,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} }
public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() { public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() {
@ -799,7 +800,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertNull($share->getExpirationDate()); $this->assertNull($share->getExpirationDate());
} }
@ -818,7 +819,7 @@ class ManagerTest extends \Test\TestCase {
$expected->setTime(0,0,0); $expected->setTime(0,0,0);
$expected->add(new \DateInterval('P3D')); $expected->add(new \DateInterval('P3D'));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertNotNull($share->getExpirationDate()); $this->assertNotNull($share->getExpirationDate());
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
@ -839,7 +840,7 @@ class ManagerTest extends \Test\TestCase {
])); ]));
try { try {
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} catch (\OCP\Share\Exceptions\GenericShareException $e) { } catch (\OCP\Share\Exceptions\GenericShareException $e) {
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getMessage()); $this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getMessage());
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getHint()); $this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getHint());
@ -871,7 +872,7 @@ class ManagerTest extends \Test\TestCase {
return $data['expirationDate'] == $future; return $data['expirationDate'] == $future;
})); }));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
@ -892,7 +893,7 @@ class ManagerTest extends \Test\TestCase {
return $data['expirationDate'] == $expected && $data['passwordSet'] === false; return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
})); }));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
@ -907,7 +908,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setPassword('password'); $share->setPassword('password');
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertNull($share->getExpirationDate()); $this->assertNull($share->getExpirationDate());
} }
@ -934,7 +935,7 @@ class ManagerTest extends \Test\TestCase {
return $data['expirationDate'] == $expected; return $data['expirationDate'] == $expected;
})); }));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
@ -955,7 +956,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($nextWeek); $share->setExpirationDate($nextWeek);
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$save->sub(new \DateInterval('P2D')); $save->sub(new \DateInterval('P2D'));
$this->assertEquals($save, $share->getExpirationDate()); $this->assertEquals($save, $share->getExpirationDate());
@ -980,7 +981,7 @@ class ManagerTest extends \Test\TestCase {
$data['message'] = 'Invalid date!'; $data['message'] = 'Invalid date!';
})); }));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} }
public function testValidateExpirationDateExistingShareNoDefault() { public function testValidateExpirationDateExistingShareNoDefault() {
@ -994,7 +995,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_expire_after_n_days', '7', '6'], ['core', 'shareapi_expire_after_n_days', '7', '6'],
])); ]));
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
$this->assertEquals(null, $share->getExpirationDate()); $this->assertEquals(null, $share->getExpirationDate());
} }
@ -1030,7 +1031,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'userCreateChecks', [$share]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
} }
public function testUserCreateChecksShareWithGroupMembersOnlySharedGroup() { public function testUserCreateChecksShareWithGroupMembersOnlySharedGroup() {
@ -1068,7 +1069,7 @@ class ManagerTest extends \Test\TestCase {
->with($path) ->with($path)
->willReturn([]); ->willReturn([]);
$this->invokePrivate($this->manager, 'userCreateChecks', [$share]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
} }
/** /**
@ -1093,7 +1094,7 @@ class ManagerTest extends \Test\TestCase {
->with($path) ->with($path)
->willReturn([$share2]); ->willReturn([$share2]);
$this->invokePrivate($this->manager, 'userCreateChecks', [$share]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
} }
/** /**
@ -1135,7 +1136,7 @@ class ManagerTest extends \Test\TestCase {
->with($path) ->with($path)
->willReturn([$share2]); ->willReturn([$share2]);
$this->invokePrivate($this->manager, 'userCreateChecks', [$share]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
} }
public function testUserCreateChecksIdenticalPathNotSharedWithUser() { public function testUserCreateChecksIdenticalPathNotSharedWithUser() {
@ -1170,7 +1171,7 @@ class ManagerTest extends \Test\TestCase {
->with($path) ->with($path)
->willReturn([$share2]); ->willReturn([$share2]);
$this->invokePrivate($this->manager, 'userCreateChecks', [$share]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
} }
/** /**
@ -1186,7 +1187,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_group_sharing', 'yes', 'no'], ['core', 'shareapi_allow_group_sharing', 'yes', 'no'],
])); ]));
$this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
} }
/** /**
@ -1212,7 +1213,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
} }
public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() { public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() {
@ -1241,7 +1242,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
} }
/** /**
@ -1272,7 +1273,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
} }
public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() { public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() {
@ -1296,7 +1297,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'groupCreateChecks', [$share]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
} }
/** /**
@ -1312,7 +1313,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'no'], ['core', 'shareapi_allow_links', 'yes', 'no'],
])); ]));
$this->invokePrivate($this->manager, 'linkCreateChecks', [$share]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
} }
/** /**
@ -1330,7 +1331,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'yes'], ['core', 'shareapi_allow_links', 'yes', 'yes'],
])); ]));
$this->invokePrivate($this->manager, 'linkCreateChecks', [$share]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
} }
/** /**
@ -1349,7 +1350,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_public_upload', 'yes', 'no'] ['core', 'shareapi_allow_public_upload', 'yes', 'no']
])); ]));
$this->invokePrivate($this->manager, 'linkCreateChecks', [$share]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
} }
public function testLinkCreateChecksPublicUpload() { public function testLinkCreateChecksPublicUpload() {
@ -1364,7 +1365,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_public_upload', 'yes', 'yes'] ['core', 'shareapi_allow_public_upload', 'yes', 'yes']
])); ]));
$this->invokePrivate($this->manager, 'linkCreateChecks', [$share]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
} }
public function testLinkCreateChecksReadOnly() { public function testLinkCreateChecksReadOnly() {
@ -1379,7 +1380,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_allow_public_upload', 'yes', 'no'] ['core', 'shareapi_allow_public_upload', 'yes', 'no']
])); ]));
$this->invokePrivate($this->manager, 'linkCreateChecks', [$share]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
} }
/** /**
@ -1397,7 +1398,7 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager->method('findIn')->with('path')->willReturn([$mount]); $this->mountManager->method('findIn')->with('path')->willReturn([$mount]);
$this->invokePrivate($this->manager, 'pathCreateChecks', [$path]); self::invokePrivate($this->manager, 'pathCreateChecks', [$path]);
} }
public function testPathCreateChecksContainsNoSharedMount() { public function testPathCreateChecksContainsNoSharedMount() {
@ -1411,13 +1412,13 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager->method('findIn')->with('path')->willReturn([$mount]); $this->mountManager->method('findIn')->with('path')->willReturn([$mount]);
$this->invokePrivate($this->manager, 'pathCreateChecks', [$path]); self::invokePrivate($this->manager, 'pathCreateChecks', [$path]);
} }
public function testPathCreateChecksContainsNoFolder() { public function testPathCreateChecksContainsNoFolder() {
$path = $this->createMock(File::class); $path = $this->createMock(File::class);
$this->invokePrivate($this->manager, 'pathCreateChecks', [$path]); self::invokePrivate($this->manager, 'pathCreateChecks', [$path]);
} }
public function dataIsSharingDisabledForUser() { public function dataIsSharingDisabledForUser() {
@ -1528,7 +1529,7 @@ class ManagerTest extends \Test\TestCase {
$exception = false; $exception = false;
try { try {
$res = $this->invokePrivate($manager, 'canShare', [$share]); $res = self::invokePrivate($manager, 'canShare', [$share]);
} catch (\Exception $e) { } catch (\Exception $e) {
$exception = true; $exception = true;
} }
@ -2008,6 +2009,12 @@ class ManagerTest extends \Test\TestCase {
} }
public function testGetShareByToken() { public function testGetShareByToken() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
$factory = $this->createMock(IProviderFactory::class); $factory = $this->createMock(IProviderFactory::class);
$manager = new Manager( $manager = new Manager(
@ -2041,6 +2048,12 @@ class ManagerTest extends \Test\TestCase {
} }
public function testGetShareByTokenWithException() { public function testGetShareByTokenWithException() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
$factory = $this->createMock(IProviderFactory::class); $factory = $this->createMock(IProviderFactory::class);
$manager = new Manager( $manager = new Manager(
@ -2085,6 +2098,12 @@ class ManagerTest extends \Test\TestCase {
* @expectedException \OCP\Share\Exceptions\ShareNotFound * @expectedException \OCP\Share\Exceptions\ShareNotFound
*/ */
public function testGetShareByTokenExpired() { public function testGetShareByTokenExpired() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
$manager = $this->createManagerMock() $manager = $this->createManagerMock()
->setMethods(['deleteShare']) ->setMethods(['deleteShare'])
->getMock(); ->getMock();
@ -2107,6 +2126,12 @@ class ManagerTest extends \Test\TestCase {
} }
public function testGetShareByTokenNotExpired() { public function testGetShareByTokenNotExpired() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
$date = new \DateTime(); $date = new \DateTime();
$date->setTime(0,0,0); $date->setTime(0,0,0);
$date->add(new \DateInterval('P2D')); $date->add(new \DateInterval('P2D'));
@ -2123,12 +2148,33 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($share, $res); $this->assertSame($share, $res);
} }
public function testGetShareByTokenPublicSharingDisabled() { /**
* @expectedException \OCP\Share\Exceptions\ShareNotFound
*/
public function testGetShareByTokenWithPublicLinksDisabled() {
$this->config
->expects($this->once())
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('no');
$this->manager->getShareByToken('validToken');
}
public function testGetShareByTokenPublicUploadDisabled() {
$this->config
->expects($this->at(0))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK) $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE); ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
$this->config->method('getAppValue')->will($this->returnValueMap([ $this->config
->expects($this->at(1))
->method('getAppValue')
->will($this->returnValueMap([
['core', 'shareapi_allow_public_upload', 'yes', 'no'], ['core', 'shareapi_allow_public_upload', 'yes', 'no'],
])); ]));