]> source.dussan.org Git - nextcloud-server.git/commitdiff
cleanup tests
authorFlorin Peter <github@florin-peter.de>
Sun, 19 May 2013 20:28:48 +0000 (22:28 +0200)
committerFlorin Peter <github@florin-peter.de>
Sun, 19 May 2013 20:28:48 +0000 (22:28 +0200)
apps/files_encryption/tests/crypt.php
apps/files_encryption/tests/keymanager.php
apps/files_encryption/tests/share.php
apps/files_encryption/tests/util.php

index 18faaceb0311e7bef79964f9755e4a55af1f1645..c669aec1222bfcca87de9ff4f050f7f6fa21d6aa 100755 (executable)
@@ -19,8 +19,25 @@ require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
 
 use OCA\Encryption;
 
+/**
+ * Class Test_Encryption_Crypt
+ */
 class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
-       
+
+       public $userId;
+       public $pass;
+       public $stateFilesTrashbin;
+       public $dataLong;
+       public $dataUrl;
+       public $dataShort;
+       /**
+        * @var OC_FilesystemView
+        */
+       public $view;
+       public $legacyEncryptedData;
+       public $genPrivateKey;
+       public $genPublicKey;
+
        function setUp() {
         // reset backend
         \OC_User::clearBackends();
@@ -93,7 +110,10 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                $this->assertTrue( strlen( $key ) > 16 );
        
        }
-       
+
+       /**
+        * @return String
+        */
        function testGenerateIv() {
                
                $iv = Encryption\Crypt::generateIv();
@@ -150,7 +170,10 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                $this->assertEquals( $this->dataLong, $splitCatfile['encrypted'] );
        
        }
-       
+
+       /**
+        * @return string padded
+        */
        function testAddPadding() {
        
                $padded = Encryption\Crypt::addPadding( $this->dataLong );
@@ -214,34 +237,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                $this->assertEquals( $this->dataShort, $decrypt );
                
        }
-       
-       // These aren't used for now
-//     function testSymmetricBlockEncryptShortFileContent() {
-//             
-//             $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataShort, $this->randomKey );
-//             
-//             $this->assertNotEquals( $this->dataShort, $crypted );
-//             
-// 
-//             $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-// 
-//             $this->assertEquals( $this->dataShort, $decrypt );
-//             
-//     }
-//     
-//     function testSymmetricBlockEncryptLongFileContent() {
-//             
-//             $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataLong, $this->randomKey );
-//             
-//             $this->assertNotEquals( $this->dataLong, $crypted );
-//             
-// 
-//             $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-// 
-//             $this->assertEquals( $this->dataLong, $decrypt );
-//             
-//     }
-       
+
        function testSymmetricStreamEncryptShortFileContent() {
                
                $filename = 'tmp-'.time().'.test';
@@ -351,9 +347,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                $decrypt = '';
                
                // Manually decrypt chunk
-               foreach ($e as $e) {
+               foreach ($e as $chunk) {
                        
-                       $chunkDecrypt = Encryption\Crypt::symmetricDecryptFileContent( $e, $plainKeyfile );
+                       $chunkDecrypt = Encryption\Crypt::symmetricDecryptFileContent( $chunk, $plainKeyfile );
                        
                        // Assemble decrypted chunks
                        $decrypt .= $chunkDecrypt;
@@ -741,7 +737,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                $this->assertEquals( $this->dataLong, $decrypt );
 
                // change password
-               \OC_User::setPassword($this->userId, 'test');
+               \OC_User::setPassword($this->userId, 'test', null);
 
                // relogin
                $params['uid'] = $this->userId;
index 48e370d3a53ae8f0ad820ef80a8cf93fd7ccc3ab..8ca8b0287e405a82e1c2630e2a219d77fd1d1bed 100644 (file)
@@ -17,8 +17,20 @@ require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
 
 use OCA\Encryption;
 
+/**
+ * Class Test_Encryption_Keymanager
+ */
 class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
-       
+
+       public $userId;
+       public $pass;
+       public $stateFilesTrashbin;
+       /**
+        * @var OC_FilesystemView
+        */
+       public $view;
+       public $randomKey;
+
        function setUp() {
         // reset backend
         \OC_User::clearBackends();
index a40a992b80464ed38d311a4006cbf47d911045b4..de02513dea3eb543aabb6082437d582bc3fb1c5f 100755 (executable)
@@ -32,10 +32,24 @@ require_once realpath(dirname(__FILE__) . '/../appinfo/app.php');
 
 use OCA\Encryption;
 
+/**
+ * Class Test_Encryption_Share
+ */
 class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
 {
 
-    function setUp()
+       public $stateFilesTrashbin;
+       public $filename;
+       public $dataShort;
+       /**
+        * @var OC_FilesystemView
+        */
+       public $view;
+       public $folder1;
+       public $subfolder;
+       public $subsubfolder;
+
+       function setUp()
     {
         // reset backend
         \OC_User::clearBackends();
@@ -106,7 +120,10 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
                \OC_FileProxy::clearProxies();
     }
 
-    function testShareFile($withTeardown = true)
+       /**
+        * @param bool $withTeardown
+        */
+       function testShareFile($withTeardown = true)
     {
         // login as admin
         $this->loginHelper('admin');
@@ -171,7 +188,10 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
         }
     }
 
-    function testReShareFile($withTeardown = true)
+       /**
+        * @param bool $withTeardown
+        */
+       function testReShareFile($withTeardown = true)
     {
         $this->testShareFile(false);
 
@@ -228,7 +248,11 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
         }
     }
 
-    function testShareFolder($withTeardown = true)
+       /**
+        * @param bool $withTeardown
+        * @return array
+        */
+       function testShareFolder($withTeardown = true)
     {
         // login as admin
         $this->loginHelper('admin');
@@ -297,7 +321,10 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
         return $fileInfo;
     }
 
-    function testReShareFolder($withTeardown = true)
+       /**
+        * @param bool $withTeardown
+        */
+       function testReShareFolder($withTeardown = true)
     {
         $fileInfoFolder1 = $this->testShareFolder(false);
 
@@ -664,6 +691,11 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
                $this->assertTrue($util->setRecoveryForUser(false));
        }
 
+       /**
+        * @param $user
+        * @param bool $create
+        * @param bool $password
+        */
        function loginHelper($user, $create = false, $password = false)
     {
         if ($create) {
index 648ca2486d7db8c10a20ab6eb51ac8e554ca8299..53ac8ee8d636544a14e4897b1d2f14ab26ddb7b7 100755 (executable)
@@ -16,8 +16,28 @@ require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
 
 use OCA\Encryption;
 
+/**
+ * Class Test_Encryption_Util
+ */
 class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
-       
+
+       public $userId;
+       public $encryptionDir;
+       public $publicKeyDir;
+       public $pass;
+       /**
+        * @var OC_FilesystemView
+        */
+       public $view;
+       public $keyfilesPath;
+       public $publicKeyPath;
+       public $privateKeyPath;
+       /**
+        * @var \OCA\Encryption\Util
+        */
+       public $util;
+       public $dataShort;
+
        function setUp() {
         // reset backend
         \OC_User::useBackend('database');