diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-05-19 16:32:09 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-19 16:32:09 +0300 |
commit | 3b3940df6b020267fc51f0f365e3a8ceb7ddc2cc (patch) | |
tree | 3f8ffa66bd19f66bc5be8623a70d3d5ee1e195aa /tests | |
parent | 61b3260ebdf9e5756719485416381fdcf4b2f589 (diff) | |
parent | f824f3e5f355d9eb15e957fad96558b3bef9f615 (diff) |
Merge pull request #24660 from owncloud/no-token-login-for-disabled-users
don't allow token login for disabled users
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/user/session.php | 32 |
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)); + } + } |