[Pkg-owncloud-commits] [owncloud] 25/42: fixing comment + adding unit test for checkPasswordProtectedShare
David Prévot
taffit at moszumanska.debian.org
Wed Jan 22 21:21:49 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit ea334cfa189ad120b1ce17749f912a791c97ec1b
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date: Tue Jan 21 12:07:08 2014 +0100
fixing comment + adding unit test for checkPasswordProtectedShare
---
lib/public/share.php | 8 +++++++-
tests/lib/share/share.php | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/lib/public/share.php b/lib/public/share.php
index ddc9e1e..f832d04 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -365,7 +365,7 @@ class Share {
return false;
}
- // password protected shares need to me authenticated
+ // password protected shares need to be authenticated
if ($checkPasswordProtection && !\OCP\Share::checkPasswordProtectedShare($row)) {
return false;
}
@@ -1907,6 +1907,12 @@ class Share {
if (!isset($linkItem['share_with'])) {
return true;
}
+ if (!isset($linkItem['share_type'])) {
+ return true;
+ }
+ if (!isset($linkItem['id'])) {
+ return true;
+ }
if ($linkItem['share_type'] != \OCP\Share::SHARE_TYPE_LINK) {
return true;
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 2fe2837..d6acee6 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -25,6 +25,8 @@ class Test_Share extends PHPUnit_Framework_TestCase {
protected $userBackend;
protected $user1;
protected $user2;
+ protected $user3;
+ protected $user4;
protected $groupBackend;
protected $group1;
protected $group2;
@@ -656,4 +658,44 @@ class Test_Share extends PHPUnit_Framework_TestCase {
'Failed asserting that the share of the test.txt file by user 2 has been removed.'
);
}
+
+ /**
+ * @dataProvider checkPasswordProtectedShareDataProvider
+ * @param $expected
+ * @param $item
+ */
+ public function testCheckPasswordProtectedShare($expected, $item) {
+ \OC::$session->set('public_link_authenticated', 100);
+ $result = \OCP\Share::checkPasswordProtectedShare($item);
+ $this->assertEquals($expected, $result);
+ }
+
+ function checkPasswordProtectedShareDataProvider() {
+ return array(
+ array(true, array()),
+ array(true, array('share_with' => null)),
+ array(true, array('share_with' => '')),
+ array(true, array('share_with' => '1234567890', 'share_type' => '1')),
+ array(true, array('share_with' => '1234567890', 'share_type' => 1)),
+ array(true, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 100)),
+ array(true, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 100)),
+ array(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 101)),
+ array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 101)),
+ );
+
+ /*
+ if (!isset($linkItem['share_with'])) {
+ return true;
+ }
+
+ if ($linkItem['share_type'] != \OCP\Share::SHARE_TYPE_LINK) {
+ return true;
+ }
+
+ if ( \OC::$session->exists('public_link_authenticated')
+ && \OC::$session->get('public_link_authenticated') === $linkItem['id'] ) {
+ return true;
+ }
+ * */
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list