]> source.dussan.org Git - nextcloud-server.git/commitdiff
add DB tests for credentials manager
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 15 Apr 2020 14:44:28 +0000 (16:44 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 15 Apr 2020 14:44:28 +0000 (16:44 +0200)
these are actually expected to FAIL, because NULL as a userid is not
allowed in the schema, but documented to be used on the source

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
tests/lib/Security/CredentialsManagerTest.php

index 8b58542f8c39ff327efd5479ac631d6422fc2e85..b5d4116b2930fb002317f424608b853ee7ae2a0d 100644 (file)
@@ -27,6 +27,9 @@ use OCP\IDBConnection;
 use OCP\ILogger;
 use OCP\Security\ICrypto;
 
+/**
+ * @group DB
+ */
 class CredentialsManagerTest extends \Test\TestCase {
 
        /** @var ICrypto */
@@ -106,4 +109,34 @@ class CredentialsManagerTest extends \Test\TestCase {
 
                $this->manager->retrieve($userId, $identifier);
        }
+
+       /**
+        * @dataProvider credentialsProvider
+        */
+       public function testWithDB($userId, $identifier) {
+               $credentialsManager = \OC::$server->getCredentialsManager();
+
+               $secrets = 'Open Sesame';
+
+               $credentialsManager->store($userId, $identifier, $secrets);
+               $received = $credentialsManager->retrieve($userId, $identifier);
+
+               $this->assertSame($secrets, $received);
+
+               $removedRows = $credentialsManager->delete($userId, $identifier);
+               $this->assertSame(1, $removedRows);
+       }
+
+       public function credentialsProvider() {
+               return [
+                       [
+                               'alice',
+                               'privateCredentials'
+                       ],
+                       [
+                               null,
+                               'systemCredentials'
+                       ]
+               ];
+       }
 }