summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-06-03 15:15:04 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-06 15:47:37 +0200
commitf15d7dfec06ff895b8956741277f5ec8d6f4fa92 (patch)
tree1787f0964bea33d9b1dad4dfdc7377ea77f2a388 /tests
parent933c05566e21c27e4f2d4b4e9c2d54e7b363d304 (diff)
downloadnextcloud-server-f15d7dfec06ff895b8956741277f5ec8d6f4fa92.tar.gz
nextcloud-server-f15d7dfec06ff895b8956741277f5ec8d6f4fa92.zip
only expire link shares
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/share.php77
1 files changed, 18 insertions, 59 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 95983ee70e6..5920b44a8e0 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -151,6 +151,12 @@ class Test_Share extends PHPUnit_Framework_TestCase {
);
}
+ protected function shareUserTestFileAsLink() {
+ OC_User::setUserId($this->user1);
+ $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ);
+ $this->assertTrue(is_string($result));
+ }
+
/**
* @param string $sharer
* @param string $receiver
@@ -316,36 +322,35 @@ class Test_Share extends PHPUnit_Framework_TestCase {
}
public function testShareWithUserExpirationExpired() {
+ OC_User::setUserId($this->user1);
$this->shareUserOneTestFileWithUserTwo();
+ $this->shareUserTestFileAsLink();
- OC_User::setUserId($this->user1);
$this->assertTrue(
OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast),
'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
);
- OC_User::setUserId($this->user2);
- $this->assertSame(array(),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 2 no longer has access to test.txt after expiration.'
- );
+ $shares = OCP\Share::getItemsShared('test');
+ $this->assertSame(1, count($shares));
+ $share = reset($shares);
+ $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']);
}
public function testShareWithUserExpirationValid() {
+ OC_User::setUserId($this->user1);
$this->shareUserOneTestFileWithUserTwo();
+ $this->shareUserTestFileAsLink();
+
- OC_User::setUserId($this->user1);
$this->assertTrue(
OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture),
'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
);
- OC_User::setUserId($this->user2);
- $this->assertEquals(
- array('test.txt'),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 2 still has access to test.txt after expiration date has been set.'
- );
+ $shares = OCP\Share::getItemsShared('test');
+ $this->assertSame(2, count($shares));
+
}
protected function shareUserOneTestFileWithGroupOne() {
@@ -516,52 +521,6 @@ class Test_Share extends PHPUnit_Framework_TestCase {
$this->assertEquals(array(), OCP\Share::getItemsShared('test'));
}
- public function testShareWithGroupExpirationExpired() {
- $this->shareUserOneTestFileWithGroupOne();
-
- OC_User::setUserId($this->user1);
- $this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast),
- 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
- );
-
- OC_User::setUserId($this->user2);
- $this->assertSame(array(),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 2 no longer has access to test.txt after expiration.'
- );
-
- OC_User::setUserId($this->user3);
- $this->assertSame(array(),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 3 no longer has access to test.txt after expiration.'
- );
- }
-
- public function testShareWithGroupExpirationValid() {
- $this->shareUserOneTestFileWithGroupOne();
-
- OC_User::setUserId($this->user1);
- $this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture),
- 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
- );
-
- OC_User::setUserId($this->user2);
- $this->assertEquals(
- array('test.txt'),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 2 still has access to test.txt after expiration date has been set.'
- );
-
- OC_User::setUserId($this->user3);
- $this->assertEquals(
- array('test.txt'),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 3 still has access to test.txt after expiration date has been set.'
- );
- }
-
/**
* @param boolean|string $token
*/