Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@owncloud.com>2016-05-17 11:32:47 +0300
committerChristoph Wurst <christoph@owncloud.com>2016-05-18 22:10:37 +0300
commitf824f3e5f355d9eb15e957fad96558b3bef9f615 (patch)
tree9e840b7acc3d89ebad3560332070c950acbb0c46 /tests
parentdc0e3617dc1c5a3d4c4fbc67e6bae957e5afff8e (diff)
don't allow token login for disabled users
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/user/session.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php
index 710d5ae20b3..444735b854f 100644
--- a/tests/lib/user/session.php
+++ b/tests/lib/user/session.php
@@ -477,4 +477,36 @@ class Session extends \Test\TestCase {
$this->assertEquals($users['bar'], $userSession->getUser());
}
+ public function testTryTokenLoginWithDisabledUser() {
+ $manager = $this->getMockBuilder('\OC\User\Manager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $session = new Memory('');
+ $token = $this->getMock('\OC\Authentication\Token\IToken');
+ $user = $this->getMock('\OCP\IUser');
+ $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider);
+ $request = $this->getMock('\OCP\IRequest');
+
+ $request->expects($this->once())
+ ->method('getHeader')
+ ->with('Authorization')
+ ->will($this->returnValue('token xxxxx'));
+ $this->defaultProvider->expects($this->once())
+ ->method('validateToken')
+ ->with('xxxxx')
+ ->will($this->returnValue($token));
+ $token->expects($this->once())
+ ->method('getUID')
+ ->will($this->returnValue('user123'));
+ $manager->expects($this->once())
+ ->method('get')
+ ->with('user123')
+ ->will($this->returnValue($user));
+ $user->expects($this->once())
+ ->method('isEnabled')
+ ->will($this->returnValue(false));
+
+ $this->assertFalse($userSession->tryTokenLogin($request));
+ }
+
}