summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-09 10:36:44 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-09 10:36:44 +0100
commit623a0e463755f9f429f1505a939f86492571f5ce (patch)
treed3d1e5e7fdf89355a7da913c27396aeefbd495b7 /apps/files_sharing/tests
parent38cbfed476b2ba1fc33564752b7e49283c657d08 (diff)
downloadnextcloud-server-623a0e463755f9f429f1505a939f86492571f5ce.tar.gz
nextcloud-server-623a0e463755f9f429f1505a939f86492571f5ce.zip
Example hook check
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index 58524d8f030..11dc082390c 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -218,12 +218,12 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testAuthenticateInvalidPassword() {
- $node = $this->getMock('\OCP\Files\File');
- $node->method('getId')->willReturn(100);
-
$share = \OC::$server->getShareManager()->newShare();
- $share->setId(42)
- ->setNode($node);
+ $share->setNodeId(100)
+ ->setNodeType('file')
+ ->setToken('token')
+ ->setSharedBy('initiator')
+ ->setId(42);
$this->shareManager
->expects($this->once())
@@ -241,6 +241,20 @@ class ShareControllerTest extends \Test\TestCase {
->expects($this->never())
->method('set');
+ $hookListner = $this->getMockBuilder('Dummy')->setMethods(['access'])->getMock();
+ \OCP\Util::connectHook('OCP\Share', 'share_link_access', $hookListner, 'access');
+
+ $hookListner->expects($this->once())
+ ->method('access')
+ ->with($this->callback(function(array $data) {
+ return $data['itemType'] === 'file' &&
+ $data['itemSource'] === 100 &&
+ $data['uidOwner'] === 'initiator' &&
+ $data['token'] === 'token' &&
+ $data['errorCode'] === 403 &&
+ $data['errorMessage'] === 'Wrong password';
+ }));
+
$response = $this->shareController->authenticate('token', 'invalidpassword');
$expectedResponse = new TemplateResponse($this->appName, 'authenticate', array('wrongpw' => true), 'guest');
$this->assertEquals($expectedResponse, $response);