summaryrefslogtreecommitdiffstats
path: root/tests/Core/Service
diff options
context:
space:
mode:
authorKonrad Abicht <hi@inspirito.de>2021-02-11 10:58:44 +0100
committerKonrad Abicht <hi@inspirito.de>2021-02-12 12:57:24 +0100
commit0bc49d67cdc09da25e828848735e41abef12a157 (patch)
tree927a25c0e875653288696bca58de09e23b50b11f /tests/Core/Service
parentc755165dd46e0bd8d8b70ed1cd2e937795fbcdc9 (diff)
downloadnextcloud-server-0bc49d67cdc09da25e828848735e41abef12a157.tar.gz
nextcloud-server-0bc49d67cdc09da25e828848735e41abef12a157.zip
added unit tests for LoginFlowV2Service::createTokens
Signed-off-by: Konrad Abicht <hi@inspirito.de>
Diffstat (limited to 'tests/Core/Service')
-rw-r--r--tests/Core/Service/LoginFlowV2ServiceUnitTest.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
index 9089d81dc94..ba0a3130af7 100644
--- a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
+++ b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
@@ -26,6 +26,7 @@ use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Core\Data\LoginFlowV2Credentials;
+use OC\Core\Data\LoginFlowV2Tokens;
use OC\Core\Db\LoginFlowV2Mapper;
use OC\Core\Db\LoginFlowV2;
use OC\Core\Exception\LoginFlowV2NotFoundException;
@@ -380,4 +381,26 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
);
$this->assertFalse($result);
}
+
+ /*
+ * Tests for createTokens
+ */
+
+ public function testCreateTokens() {
+ $this->config->expects($this->exactly(2))
+ ->method('getSystemValue')
+ ->willReturn($this->returnCallback(function ($key) {
+ // Note: \OCP\IConfig::getSystemValue returns either an array or string.
+ return 'openssl' == $key ? [] : '';
+ }));
+
+ $this->mapper->expects($this->once())
+ ->method('insert');
+
+ $this->secureRandom->expects($this->exactly(2))
+ ->method('generate');
+
+ $token = $this->subjectUnderTest->createTokens('user_agent');
+ $this->assertTrue($token instanceof LoginFlowV2Tokens);
+ }
}