summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-06-13 14:59:38 -0500
committerGitHub <noreply@github.com>2017-06-13 14:59:38 -0500
commit101d1c0f8185925cf8e22b893be397a25290f128 (patch)
tree2f7f2efcd0a5011dca8659910f40aafd455517ee
parent69fd3a3c7bf12c45d8bb6577625efbcc2f1c17e9 (diff)
parent0f8c1b13a39541fecdb149f41e9904d89a60ea64 (diff)
downloadnextcloud-server-101d1c0f8185925cf8e22b893be397a25290f128.tar.gz
nextcloud-server-101d1c0f8185925cf8e22b893be397a25290f128.zip
Merge pull request #5367 from nextcloud/better-share-error
Better error message on invalid sharing link
-rw-r--r--lib/private/Share20/Manager.php4
-rw-r--r--tests/lib/Share20/ManagerTest.php5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 06d03f2ec7c..57ba39d41f6 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1090,7 +1090,7 @@ class Manager implements IManager {
}
if ($share === null) {
- throw new ShareNotFound();
+ throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
$this->checkExpireDate($share);
@@ -1110,7 +1110,7 @@ class Manager implements IManager {
if ($share->getExpirationDate() !== null &&
$share->getExpirationDate() <= new \DateTime()) {
$this->deleteShare($share);
- throw new ShareNotFound();
+ throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
}
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 13556285b61..79af2f60ce8 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -2142,6 +2142,7 @@ class ManagerTest extends \Test\TestCase {
/**
* @expectedException \OCP\Share\Exceptions\ShareNotFound
+ * @expectedExceptionMessage The requested share does not exist anymore
*/
public function testGetShareByTokenExpired() {
$this->config
@@ -2150,6 +2151,10 @@ class ManagerTest extends \Test\TestCase {
->with('core', 'shareapi_allow_links', 'yes')
->willReturn('yes');
+ $this->l->expects($this->once())
+ ->method('t')
+ ->willReturnArgument(0);
+
$manager = $this->createManagerMock()
->setMethods(['deleteShare'])
->getMock();