Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-12-03 19:20:04 +0300
committerJoas Schilling <nickvergessen@gmx.de>2014-12-09 11:47:27 +0300
commitb85e34c1da075ad551321541a4e75d0d3a7015a5 (patch)
tree8e5a85b5e4e77a9fd744d6e89ad594e8a2d02c38 /apps/files_encryption/tests/crypt.php
parente67fe0336bde1b10c1b2ba3dc455a9106cfc4be9 (diff)
Correctly namespace encryption tests
Diffstat (limited to 'apps/files_encryption/tests/crypt.php')
-rwxr-xr-xapps/files_encryption/tests/crypt.php54
1 files changed, 27 insertions, 27 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index d57fec18ebd..451fa62fe57 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -7,12 +7,12 @@
* See the COPYING-README file.
*/
-use OCA\Files_Encryption\Crypt;
+namespace OCA\Files_Encryption\Tests;
/**
- * Class Test_Encryption_Crypt
+ * Class Crypt
*/
-class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
+class Crypt extends TestCase {
const TEST_ENCRYPTION_CRYPT_USER1 = "test-crypt-user1";
@@ -23,7 +23,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
public $dataUrl;
public $dataShort;
/**
- * @var OC\Files\View
+ * @var \OC\Files\View
*/
public $view;
public $legacyEncryptedData;
@@ -52,16 +52,16 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
$this->legacyData = __DIR__ . '/legacy-text.txt';
$this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
$this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
- $this->randomKey = Crypt::generateKey();
+ $this->randomKey = \OCA\Files_Encryption\Crypt::generateKey();
- $keypair = Crypt::createKeypair();
+ $keypair = \OCA\Files_Encryption\Crypt::createKeypair();
$this->genPublicKey = $keypair['publicKey'];
$this->genPrivateKey = $keypair['privateKey'];
$this->view = new \OC\Files\View('/');
// remember files_trashbin state
- $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
+ $this->stateFilesTrashbin = \OC_App::isEnabled('files_trashbin');
// we don't want to tests with app files_trashbin enabled
\OC_App::disable('files_trashbin');
@@ -70,9 +70,9 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
protected function tearDown() {
// reset app files_trashbin
if ($this->stateFilesTrashbin) {
- OC_App::enable('files_trashbin');
+ \OC_App::enable('files_trashbin');
} else {
- OC_App::disable('files_trashbin');
+ \OC_App::disable('files_trashbin');
}
$this->assertTrue(\OC_FileProxy::$enabled);
@@ -95,7 +95,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
# TODO: use more accurate (larger) string length for test confirmation
- $key = Crypt::generateKey();
+ $key = \OCA\Files_Encryption\Crypt::generateKey();
$this->assertTrue(strlen($key) > 16);
@@ -104,16 +104,16 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
public function testDecryptPrivateKey() {
// test successful decrypt
- $crypted = Crypt::symmetricEncryptFileContent($this->genPrivateKey, 'hat');
+ $crypted = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($this->genPrivateKey, 'hat');
- $header = Crypt::generateHeader();
+ $header = \OCA\Files_Encryption\Crypt::generateHeader();
- $decrypted = Crypt::decryptPrivateKey($header . $crypted, 'hat');
+ $decrypted = \OCA\Files_Encryption\Crypt::decryptPrivateKey($header . $crypted, 'hat');
$this->assertEquals($this->genPrivateKey, $decrypted);
//test private key decrypt with wrong password
- $wrongPasswd = Crypt::decryptPrivateKey($crypted, 'hat2');
+ $wrongPasswd = \OCA\Files_Encryption\Crypt::decryptPrivateKey($crypted, 'hat2');
$this->assertEquals(false, $wrongPasswd);
@@ -127,12 +127,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
- $crypted = Crypt::symmetricEncryptFileContent($this->dataShort, 'hat');
+ $crypted = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($this->dataShort, 'hat');
$this->assertNotEquals($this->dataShort, $crypted);
- $decrypt = Crypt::symmetricDecryptFileContent($crypted, 'hat');
+ $decrypt = \OCA\Files_Encryption\Crypt::symmetricDecryptFileContent($crypted, 'hat');
$this->assertEquals($this->dataShort, $decrypt);
@@ -145,12 +145,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
- $crypted = Crypt::symmetricEncryptFileContent($this->dataShort, 'hat', 'AES-128-CFB');
+ $crypted = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($this->dataShort, 'hat', 'AES-128-CFB');
$this->assertNotEquals($this->dataShort, $crypted);
- $decrypt = Crypt::symmetricDecryptFileContent($crypted, 'hat', 'AES-128-CFB');
+ $decrypt = \OCA\Files_Encryption\Crypt::symmetricDecryptFileContent($crypted, 'hat', 'AES-128-CFB');
$this->assertEquals($this->dataShort, $decrypt);
@@ -348,7 +348,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
// remove the header to check if we can also decrypt old files without a header,
// this files should fall back to AES-128
- $cryptedWithoutHeader = substr($retreivedCryptedFile, Crypt::BLOCKSIZE);
+ $cryptedWithoutHeader = substr($retreivedCryptedFile, \OCA\Files_Encryption\Crypt::BLOCKSIZE);
$this->view->file_put_contents($this->userId . '/files/' . $filename, $cryptedWithoutHeader);
// Re-enable proxy - our work is done
@@ -367,13 +367,13 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
*/
public function testIsEncryptedContent() {
- $this->assertFalse(Crypt::isCatfileContent($this->dataUrl));
+ $this->assertFalse(\OCA\Files_Encryption\Crypt::isCatfileContent($this->dataUrl));
- $this->assertFalse(Crypt::isCatfileContent($this->legacyEncryptedData));
+ $this->assertFalse(\OCA\Files_Encryption\Crypt::isCatfileContent($this->legacyEncryptedData));
- $keyfileContent = Crypt::symmetricEncryptFileContent($this->dataUrl, 'hat', 'AES-128-CFB');
+ $keyfileContent = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($this->dataUrl, 'hat', 'AES-128-CFB');
- $this->assertTrue(Crypt::isCatfileContent($keyfileContent));
+ $this->assertTrue(\OCA\Files_Encryption\Crypt::isCatfileContent($keyfileContent));
}
@@ -384,7 +384,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
- $pair1 = Crypt::createKeypair();
+ $pair1 = \OCA\Files_Encryption\Crypt::createKeypair();
$this->assertEquals(2, count($pair1));
@@ -393,12 +393,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
$this->assertTrue(strlen($pair1['privateKey']) > 1);
- $crypted = Crypt::multiKeyEncrypt($this->dataShort, array($pair1['publicKey']));
+ $crypted = \OCA\Files_Encryption\Crypt::multiKeyEncrypt($this->dataShort, array($pair1['publicKey']));
$this->assertNotEquals($this->dataShort, $crypted['data']);
- $decrypt = Crypt::multiKeyDecrypt($crypted['data'], $crypted['keys'][0], $pair1['privateKey']);
+ $decrypt = \OCA\Files_Encryption\Crypt::multiKeyDecrypt($crypted['data'], $crypted['keys'][0], $pair1['privateKey']);
$this->assertEquals($this->dataShort, $decrypt);
@@ -529,7 +529,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
// relogin
$params['uid'] = $this->userId;
$params['password'] = 'test';
- OCA\Files_Encryption\Hooks::login($params);
+ \OCA\Files_Encryption\Hooks::login($params);
// Get file decrypted contents
$newDecrypt = file_get_contents('crypt:///' . $this->userId . '/files/' . $filename);