summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/lib/SessionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/lib/SessionTest.php')
-rw-r--r--apps/encryption/tests/lib/SessionTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/encryption/tests/lib/SessionTest.php b/apps/encryption/tests/lib/SessionTest.php
index e036c439939..0fa48666d70 100644
--- a/apps/encryption/tests/lib/SessionTest.php
+++ b/apps/encryption/tests/lib/SessionTest.php
@@ -56,6 +56,7 @@ class SessionTest extends TestCase {
* @depends testSetAndGetPrivateKey
*/
public function testIsPrivateKeySet() {
+ $this->instance->setPrivateKey('dummyPrivateKey');
$this->assertTrue($this->instance->isPrivateKeySet());
unset(self::$tempStorage['privateKey']);
@@ -65,6 +66,51 @@ class SessionTest extends TestCase {
self::$tempStorage['privateKey'] = 'dummyPrivateKey';
}
+ public function testDecryptAllModeActivated() {
+ $this->instance->prepareDecryptAll('user1', 'usersKey');
+ $this->assertTrue($this->instance->decryptAllModeActivated());
+ $this->assertSame('user1', $this->instance->getDecryptAllUid());
+ $this->assertSame('usersKey', $this->instance->getDecryptAllKey());
+ }
+
+ public function testDecryptAllModeDeactivated() {
+ $this->assertFalse($this->instance->decryptAllModeActivated());
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectExceptionMessage 'Please activate decrypt all mode first'
+ */
+ public function testGetDecryptAllUidException() {
+ $this->instance->getDecryptAllUid();
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectExceptionMessage 'No uid found while in decrypt all mode'
+ */
+ public function testGetDecryptAllUidException2() {
+ $this->instance->prepareDecryptAll(null, 'key');
+ $this->instance->getDecryptAllUid();
+ }
+
+ /**
+ * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
+ * @expectExceptionMessage 'Please activate decrypt all mode first'
+ */
+ public function testGetDecryptAllKeyException() {
+ $this->instance->getDecryptAllKey();
+ }
+
+ /**
+ * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
+ * @expectExceptionMessage 'No key found while in decrypt all mode'
+ */
+ public function testGetDecryptAllKeyException2() {
+ $this->instance->prepareDecryptAll('user', null);
+ $this->instance->getDecryptAllKey();
+ }
+
/**
*
*/
@@ -112,6 +158,10 @@ class SessionTest extends TestCase {
*
*/
public function testClearWillRemoveValues() {
+ $this->instance->setPrivateKey('privateKey');
+ $this->instance->setStatus('initStatus');
+ $this->instance->prepareDecryptAll('user', 'key');
+ $this->assertNotEmpty(self::$tempStorage);
$this->instance->clear();
$this->assertEmpty(self::$tempStorage);
}
@@ -138,4 +188,9 @@ class SessionTest extends TestCase {
$this->instance = new Session($this->sessionMock);
}
+
+ protected function tearDown() {
+ self::$tempStorage = [];
+ parent::tearDown();
+ }
}