summaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-06-27 18:23:00 +0200
committerLukas Reschke <lukas@owncloud.com>2016-06-27 18:23:00 +0200
commit6670d3765881a1a7579bd96a523a90c2a52aec4a (patch)
tree4251976f5699d7b9e0b1b0aa42b3a5baca5432b5 /tests/lib/User
parentcee2f5dc65f743e0e6470e852978d8bb8e346012 (diff)
parentf8fa031e9f81ba052930d2de647d997af3c309c6 (diff)
downloadnextcloud-server-6670d3765881a1a7579bd96a523a90c2a52aec4a.tar.gz
nextcloud-server-6670d3765881a1a7579bd96a523a90c2a52aec4a.zip
Merge remote-tracking branch 'upstream/master' into master-sync-upstream
Diffstat (limited to 'tests/lib/User')
-rw-r--r--tests/lib/User/SessionTest.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index eef4c7ff5ea..447c6142f34 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -315,6 +315,36 @@ class SessionTest extends \Test\TestCase {
}
/**
+ * When using a device token, the loginname must match the one that was used
+ * when generating the token on the browser.
+ */
+ public function testLoginWithDifferentTokenLoginName() {
+ $session = $this->getMock('\OC\Session\Memory', array(), array(''));
+ $manager = $this->getMock('\OC\User\Manager');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
+ $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config);
+ $username = 'user123';
+ $token = new \OC\Authentication\Token\DefaultToken();
+ $token->setLoginName($username);
+
+ $session->expects($this->never())
+ ->method('set');
+ $session->expects($this->once())
+ ->method('regenerateId');
+ $this->tokenProvider->expects($this->once())
+ ->method('getToken')
+ ->with('bar')
+ ->will($this->returnValue($token));
+
+ $manager->expects($this->once())
+ ->method('checkPassword')
+ ->with('foo', 'bar')
+ ->will($this->returnValue(false));
+
+ $userSession->login('foo', 'bar');
+ }
+
+ /**
* @expectedException \OC\Authentication\Exceptions\PasswordLoginForbiddenException
*/
public function testLogClientInNoTokenPasswordWith2fa() {