diff options
Diffstat (limited to 'apps/encryption/tests/lib/crypto/encryptionTest.php')
-rw-r--r-- | apps/encryption/tests/lib/crypto/encryptionTest.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php index aa28a8b44a4..d33aff877bf 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/lib/crypto/encryptionTest.php @@ -42,6 +42,9 @@ class EncryptionTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $loggerMock; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + private $l10nMock; + public function setUp() { parent::setUp(); @@ -57,12 +60,20 @@ class EncryptionTest extends TestCase { $this->loggerMock = $this->getMockBuilder('OCP\ILogger') ->disableOriginalConstructor() ->getMock(); + $this->l10nMock = $this->getMockBuilder('OCP\IL10N') + ->disableOriginalConstructor() + ->getMock(); + $this->l10nMock->expects($this->any()) + ->method('t') + ->with($this->anything()) + ->willReturnArgument(0); $this->instance = new Encryption( $this->cryptMock, $this->keyManagerMock, $this->utilMock, - $this->loggerMock + $this->loggerMock, + $this->l10nMock ); } @@ -220,4 +231,36 @@ class EncryptionTest extends TestCase { ); } + /** + * by default the encryption module should encrypt regular files, files in + * files_versions and files in files_trashbin + * + * @dataProvider dataTestShouldEncrypt + */ + public function testShouldEncrypt($path, $expected) { + $this->assertSame($expected, + $this->instance->shouldEncrypt($path) + ); + } + + public function dataTestShouldEncrypt() { + return array( + array('/user1/files/foo.txt', true), + array('/user1/files_versions/foo.txt', true), + array('/user1/files_trashbin/foo.txt', true), + array('/user1/some_folder/foo.txt', false), + array('/user1/foo.txt', false), + array('/user1/files', false), + array('/user1/files_trashbin', false), + array('/user1/files_versions', false), + ); + } + + /** + * @expectedException \OC\Encryption\Exceptions\DecryptionFailedException + * @expectedExceptionMessage Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you. + */ + public function testDecrypt() { + $this->instance->decrypt('abc'); + } } |