Skip to content

Commit

Permalink
Merge pull request #16594 from nextcloud/tech-debt/noid/remove-unused…
Browse files Browse the repository at this point in the history
…-checkPasswordProtectedShare

Remove unused OC\Share\Share::checkPasswordProtectedShare
  • Loading branch information
nickvergessen authored Jul 30, 2019
2 parents 53330ce + 98237d2 commit d4eb848
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
29 changes: 0 additions & 29 deletions lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -1326,35 +1326,6 @@ private static function insertShare(array $shareData) {

}

/**
* In case a password protected link is not yet authenticated this function will return false
*
* @param array $linkItem
* @return boolean
*/
public static function checkPasswordProtectedShare(array $linkItem) {
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;
}

if ( \OC::$server->getSession()->exists('public_link_authenticated')
&& \OC::$server->getSession()->get('public_link_authenticated') === (string)$linkItem['id'] ) {
return true;
}

return false;
}

/**
* construct select statement
* @param int $format
Expand Down
29 changes: 0 additions & 29 deletions tests/lib/Share/ShareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,35 +222,6 @@ public function verifyResult($result, $expected) {
$this->assertEmpty($expected, 'did not found all expected values');
}

/**
* @dataProvider checkPasswordProtectedShareDataProvider
* @param $expected
* @param $item
*/
public function testCheckPasswordProtectedShare($expected, $item) {
\OC::$server->getSession()->set('public_link_authenticated', '100');
$result = \OC\Share\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(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')),
array(false, array('share_with' => '1234567890', 'share_type' => '3', 'id' => 101)),
array(false, array('share_with' => '1234567890', 'share_type' => 3, 'id' => 101)),
);
}

/**
* @dataProvider urls
* @param string $url
Expand Down

0 comments on commit d4eb848

Please sign in to comment.