]> source.dussan.org Git - nextcloud-server.git/commitdiff
added unit tests for LoginFlowV2Service::createTokens
authorKonrad Abicht <hi@inspirito.de>
Thu, 11 Feb 2021 09:58:44 +0000 (10:58 +0100)
committerKonrad Abicht <hi@inspirito.de>
Fri, 12 Feb 2021 11:57:24 +0000 (12:57 +0100)
Signed-off-by: Konrad Abicht <hi@inspirito.de>
tests/Core/Service/LoginFlowV2ServiceUnitTest.php

index 9089d81dc943ec9f2ab1260fac7297ff13963c6b..ba0a3130af7ce157b66c8a21ed795217d3ed5e2b 100644 (file)
@@ -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);
+       }
 }