diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-04-15 16:44:28 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-04-15 16:44:28 +0200 |
commit | f6cb45203755d85b33684b1dab1a91b5b05e8c9a (patch) | |
tree | 908124f89b33ba28b9f24c7b7d9dcc5227a79db1 /tests | |
parent | 8bc381f1040a207dd090fccc26531ad79f355916 (diff) | |
download | nextcloud-server-f6cb45203755d85b33684b1dab1a91b5b05e8c9a.tar.gz nextcloud-server-f6cb45203755d85b33684b1dab1a91b5b05e8c9a.zip |
add DB tests for credentials manager
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Security/CredentialsManagerTest.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php index 8b58542f8c3..b5d4116b293 100644 --- a/tests/lib/Security/CredentialsManagerTest.php +++ b/tests/lib/Security/CredentialsManagerTest.php @@ -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' + ] + ]; + } } |