diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-03-19 10:47:09 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-03-19 10:47:09 +0100 |
commit | dd3307dd19bb2b61b194ba7962035a6ceae64249 (patch) | |
tree | e4ba5fc657e2267e461c8720db1568368c4a4d0e /tests/lib/share | |
parent | 3c39658a1ca3a720072df3d98fa012208c6f73e3 (diff) | |
download | nextcloud-server-dd3307dd19bb2b61b194ba7962035a6ceae64249.tar.gz nextcloud-server-dd3307dd19bb2b61b194ba7962035a6ceae64249.zip |
Added unit test
Tests added to make sure that removing an expire date when this is
enforced is not allowed.
Diffstat (limited to 'tests/lib/share')
-rw-r--r-- | tests/lib/share/share.php | 35 |
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 { |