summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/lib
diff options
context:
space:
mode:
authorClark Tomlinson <fallen013@gmail.com>2015-03-24 17:29:10 -0400
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commit0c2f9ca849ef41232511cf576cc9a9de2caa43f0 (patch)
treea75194b573985da4a68684cb5a74c9891db34696 /apps/encryption/tests/lib
parent506222567e71fc0d77fa77ee7805c93fa7655b6c (diff)
downloadnextcloud-server-0c2f9ca849ef41232511cf576cc9a9de2caa43f0.tar.gz
nextcloud-server-0c2f9ca849ef41232511cf576cc9a9de2caa43f0.zip
Updating keystorage movement and fixing hooks
Diffstat (limited to 'apps/encryption/tests/lib')
-rw-r--r--apps/encryption/tests/lib/KeyManagerTest.php39
-rw-r--r--apps/encryption/tests/lib/MigratorTest.php3
2 files changed, 33 insertions, 9 deletions
diff --git a/apps/encryption/tests/lib/KeyManagerTest.php b/apps/encryption/tests/lib/KeyManagerTest.php
index 260e69a73bf..01c5e1d2d07 100644
--- a/apps/encryption/tests/lib/KeyManagerTest.php
+++ b/apps/encryption/tests/lib/KeyManagerTest.php
@@ -27,33 +27,42 @@ class KeyManagerTest extends TestCase {
*/
private $dummyKeys;
+ /**
+ *
+ */
public function setUp() {
parent::setUp();
- $keyStorageMock = $this->getMock('OCP\Encryption\IKeyStorage');
- $cryptMock = $this->getMockBuilder('OCA\Encryption\Crypt')
+ $keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
+ $keyStorageMock->method('getUserKey')
+ ->will($this->returnValue(false));
+ $keyStorageMock->method('setUserKey')
+ ->will($this->returnValue(true));
+ $cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')
->disableOriginalConstructor()
->getMock();
$configMock = $this->getMock('OCP\IConfig');
- $userMock = $this->getMock('OCP\IUser');
- $userMock->expects($this->once())
+ $userMock = $this->getMock('OCP\IUserSession');
+ $userMock
->method('getUID')
->will($this->returnValue('admin'));
+ $cacheMock = $this->getMock('OCP\ICacheFactory');
+ $logMock = $this->getMock('OCP\ILogger');
$this->userId = 'admin';
- $this->instance = new KeyManager($keyStorageMock, $cryptMock, $configMock, $userMock);
+ $this->instance = new KeyManager($keyStorageMock, $cryptMock, $configMock, $userMock, $cacheMock, $logMock);
$this->dummyKeys = ['public' => 'randomweakpublickeyhere',
'private' => 'randomweakprivatekeyhere'];
}
/**
- * @expectedException OC\Encryption\Exceptions\PrivateKeyMissingException
+ * @expectedException \OC\Encryption\Exceptions\PrivateKeyMissingException
*/
public function testGetPrivateKey() {
$this->assertFalse($this->instance->getPrivateKey($this->userId));
}
/**
- * @expectedException OC\Encryption\Exceptions\PublicKeyMissingException
+ * @expectedException \OC\Encryption\Exceptions\PublicKeyMissingException
*/
public function testGetPublicKey() {
$this->assertFalse($this->instance->getPublicKey($this->userId));
@@ -73,18 +82,34 @@ class KeyManagerTest extends TestCase {
$this->assertFalse($this->instance->checkRecoveryPassword('pass'));
}
+ /**
+ *
+ */
public function testSetPublicKey() {
$this->assertTrue($this->instance->setPublicKey($this->userId, $this->dummyKeys['public']));
}
+ /**
+ *
+ */
public function testSetPrivateKey() {
$this->assertTrue($this->instance->setPrivateKey($this->userId, $this->dummyKeys['private']));
}
+ /**
+ *
+ */
public function testUserHasKeys() {
$this->assertFalse($this->instance->userHasKeys($this->userId));
}
+ /**
+ *
+ */
+ public function testInit() {
+ $this->assertFalse($this->instance->init($this->userId, 'pass'));
+ }
+
}
diff --git a/apps/encryption/tests/lib/MigratorTest.php b/apps/encryption/tests/lib/MigratorTest.php
index a9d57b34209..0d30b9865b9 100644
--- a/apps/encryption/tests/lib/MigratorTest.php
+++ b/apps/encryption/tests/lib/MigratorTest.php
@@ -51,8 +51,7 @@ class MigratorTest extends TestCase {
parent::setUp();
$cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock();
- $this->instance = new Migrator($this->getMock('OCP\IUser'),
- $this->getMock('OCP\IConfig'),
+ $this->instance = new Migrator($this->getMock('OCP\IConfig'),
$this->getMock('OCP\IUserManager'),
$this->getMock('OCP\ILogger'),
$cryptMock);