summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-19 17:06:04 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-19 17:06:04 +0100
commit857b22c61be8f78581f41ac155efeff34ed335cd (patch)
tree381c0564f571ecfcf11b9153735976912261b4c8 /tests/lib
parent3765af4edf6662b29881f0b430e4080301c1b2fc (diff)
parentdd3307dd19bb2b61b194ba7962035a6ceae64249 (diff)
downloadnextcloud-server-857b22c61be8f78581f41ac155efeff34ed335cd.tar.gz
nextcloud-server-857b22c61be8f78581f41ac155efeff34ed335cd.zip
Merge pull request #15025 from rullzer/ocs_respect_enforced_date
Ocs respect enforced date
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/share/share.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 1ef62dc2b07..42bb82968af 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -1051,6 +1051,41 @@ class Test_Share extends \Test\TestCase {
),
);
}
+
+ /**
+ * Ensure that we do not allow removing a an expiration date from a link share if this
+ * is enforced by the settings.
+ */
+ public function testClearExpireDateWhileEnforced() {
+ OC_User::setUserId($this->user1);
+
+ \OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes');
+ \OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2');
+ \OC_Appconfig::setValue('core', 'shareapi_enforce_expire_date', 'yes');
+
+ $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ $this->assertInternalType(
+ 'string',
+ $token,
+ 'Failed asserting that user 1 successfully shared text.txt as link with token.'
+ );
+
+ $setExpireDateFailed = false;
+ try {
+ $this->assertTrue(
+ OCP\Share::setExpirationDate('test', 'test.txt', '', ''),
+ 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
+ );
+ } catch (\Exception $e) {
+ $setExpireDateFailed = true;
+ }
+
+ $this->assertTrue($setExpireDateFailed);
+
+ \OC_Appconfig::deleteKey('core', 'shareapi_default_expire_date');
+ \OC_Appconfig::deleteKey('core', 'shareapi_expire_after_n_days');
+ \OC_Appconfig::deleteKey('core', 'shareapi_enforce_expire_date');
+ }
}
class DummyShareClass extends \OC\Share\Share {