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>
This commit is contained in:
Arthur Schiwon 2020-04-15 16:44:28 +02:00
parent 8bc381f104
commit f6cb452037
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 33 additions and 0 deletions

View 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'
]
];
}
}