diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 12:07:04 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 12:20:43 +0100 |
commit | 8a401ee15687059836c93dda62ee5ea3fbf800cf (patch) | |
tree | 8326dc5b2df8660f47946926af30d330c234e6f3 /apps/encryption/tests | |
parent | 558a934842a9f66a873f24b8107fca1fc68fb791 (diff) | |
download | nextcloud-server-8a401ee15687059836c93dda62ee5ea3fbf800cf.tar.gz nextcloud-server-8a401ee15687059836c93dda62ee5ea3fbf800cf.zip |
check if session is initialized
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r-- | apps/encryption/tests/Crypto/EncryptionTest.php | 15 | ||||
-rw-r--r-- | apps/encryption/tests/SessionTest.php | 26 |
2 files changed, 41 insertions, 0 deletions
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 658f6275bb4..3525d2d4aec 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -280,6 +280,21 @@ class EncryptionTest extends TestCase { } /** + * test begin() if encryption is not initialized but the master key is enabled + * in this case we can initialize the encryption without a username/password + * and continue + */ + public function testBeginInitMasterKey() { + + $this->sessionMock->expects($this->once())->method('isReady')->willReturn(false); + $this->utilMock->expects($this->once())->method('isMasterKeyEnabled') + ->willReturn(true); + $this->keyManagerMock->expects($this->once())->method('init')->with('', ''); + + $this->instance->begin('/user/files/welcome.txt', 'user', 'r', [], []); + } + + /** * @dataProvider dataTestUpdate * * @param string $fileKey diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php index 099acddbca1..3000fedf2c3 100644 --- a/apps/encryption/tests/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -134,6 +134,32 @@ class SessionTest extends TestCase { } /** + * @dataProvider dataTestIsReady + * + * @param int $status + * @param bool $expected + */ + public function testIsReady($status, $expected) { + /** @var Session | \PHPUnit_Framework_MockObject_MockObject $instance */ + $instance = $this->getMockBuilder(Session::class) + ->setConstructorArgs([$this->sessionMock]) + ->setMethods(['getStatus'])->getMock(); + + $instance->expects($this->once())->method('getStatus') + ->willReturn($status); + + $this->assertSame($expected, $instance->isReady()); + } + + public function dataTestIsReady() { + return [ + [Session::INIT_SUCCESSFUL, true], + [Session::INIT_EXECUTED, false], + [Session::NOT_INITIALIZED, false], + ]; + } + + /** * @param $key * @param $value */ |