diff options
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r-- | apps/encryption/tests/Crypto/CryptTest.php | 48 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/EncryptionTest.php | 62 | ||||
-rw-r--r-- | apps/encryption/tests/KeyManagerTest.php | 14 |
3 files changed, 62 insertions, 62 deletions
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 7428b3fe1af..31b61ee0664 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -80,7 +80,7 @@ class CryptTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) - ->willReturn(array()); + ->willReturn([]); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig'); $this->assertSame(1, count($result)); @@ -96,7 +96,7 @@ class CryptTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) - ->willReturn(array('foo' => 'bar', 'private_key_bits' => 1028)); + ->willReturn(['foo' => 'bar', 'private_key_bits' => 1028]); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig'); $this->assertSame(2, count($result)); @@ -185,14 +185,14 @@ class CryptTest extends TestCase { * @return array */ public function dataProviderGetCipher() { - return array( - array('AES-128-CFB', 'AES-128-CFB'), - array('AES-256-CFB', 'AES-256-CFB'), - array('AES-128-CTR', 'AES-128-CTR'), - array('AES-256-CTR', 'AES-256-CTR'), + return [ + ['AES-128-CFB', 'AES-128-CFB'], + ['AES-256-CFB', 'AES-256-CFB'], + ['AES-128-CTR', 'AES-128-CTR'], + ['AES-256-CTR', 'AES-256-CTR'], - array('unknown', 'AES-256-CTR') - ); + ['unknown', 'AES-256-CTR'] + ]; } /** @@ -203,7 +203,7 @@ class CryptTest extends TestCase { $result = self::invokePrivate( $this->crypt, 'concatIV', - array('content', 'my_iv')); + ['content', 'my_iv']); $this->assertSame('content00iv00my_iv', $result @@ -214,7 +214,7 @@ class CryptTest extends TestCase { * @dataProvider dataTestSplitMetaData */ public function testSplitMetaData($data, $expected) { - $result = self::invokePrivate($this->crypt, 'splitMetaData', array($data, 'AES-256-CFB')); + $result = self::invokePrivate($this->crypt, 'splitMetaData', [$data, 'AES-256-CFB']); $this->assertTrue(is_array($result)); $this->assertSame(3, count($result)); $this->assertArrayHasKey('encrypted', $result); @@ -239,7 +239,7 @@ class CryptTest extends TestCase { */ public function testHasSignature($data, $expected) { $this->assertSame($expected, - $this->invokePrivate($this->crypt, 'hasSignature', array($data, 'AES-256-CFB')) + $this->invokePrivate($this->crypt, 'hasSignature', [$data, 'AES-256-CFB']) ); } @@ -257,7 +257,7 @@ class CryptTest extends TestCase { $this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class); $data = 'encryptedContent00iv001234567890123456xx'; - $this->invokePrivate($this->crypt, 'hasSignature', array($data, $cipher)); + $this->invokePrivate($this->crypt, 'hasSignature', [$data, $cipher]); } public function dataTestHasSignatureFail() { @@ -273,7 +273,7 @@ class CryptTest extends TestCase { * test addPadding() */ public function testAddPadding() { - $result = self::invokePrivate($this->crypt, 'addPadding', array('data')); + $result = self::invokePrivate($this->crypt, 'addPadding', ['data']); $this->assertSame('dataxxx', $result); } @@ -285,7 +285,7 @@ class CryptTest extends TestCase { * @param $expected */ public function testRemovePadding($data, $expected) { - $result = self::invokePrivate($this->crypt, 'removePadding', array($data)); + $result = self::invokePrivate($this->crypt, 'removePadding', [$data]); $this->assertSame($expected, $result); } @@ -295,10 +295,10 @@ class CryptTest extends TestCase { * @return array */ public function dataProviderRemovePadding() { - return array( - array('dataxx', 'data'), - array('data', false) - ); + return [ + ['dataxx', 'data'], + ['data', false] + ]; } /** @@ -307,7 +307,7 @@ class CryptTest extends TestCase { public function testParseHeader() { $header= 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND'; - $result = self::invokePrivate($this->crypt, 'parseHeader', array($header)); + $result = self::invokePrivate($this->crypt, 'parseHeader', [$header]); $this->assertTrue(is_array($result)); $this->assertSame(2, count($result)); @@ -331,15 +331,15 @@ class CryptTest extends TestCase { $this->assertTrue(is_string($iv)); $this->assertSame(16, strlen($iv)); - $result = self::invokePrivate($this->crypt, 'encrypt', array($decrypted, $iv, $password)); + $result = self::invokePrivate($this->crypt, 'encrypt', [$decrypted, $iv, $password]); $this->assertTrue(is_string($result)); - return array( + return [ 'password' => $password, 'iv' => $iv, 'encrypted' => $result, - 'decrypted' => $decrypted); + 'decrypted' => $decrypted]; } @@ -353,7 +353,7 @@ class CryptTest extends TestCase { $result = self::invokePrivate( $this->crypt, 'decrypt', - array($data['encrypted'], $data['iv'], $data['password'])); + [$data['encrypted'], $data['iv'], $data['password']]); $this->assertSame($data['decrypted'], $result); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 9a541880e79..cebb27580e2 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -124,7 +124,7 @@ class EncryptionTest extends TestCase { * test if public key from one of the recipients is missing */ public function testEndUser1() { - $this->instance->begin('/foo/bar', 'user1', 'r', array(), array('users' => array('user1', 'user2', 'user3'))); + $this->instance->begin('/foo/bar', 'user1', 'r', [], ['users' => ['user1', 'user2', 'user3']]); $this->endTest(); } @@ -135,7 +135,7 @@ class EncryptionTest extends TestCase { public function testEndUser2() { $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class); - $this->instance->begin('/foo/bar', 'user2', 'r', array(), array('users' => array('user1', 'user2', 'user3'))); + $this->instance->begin('/foo/bar', 'user2', 'r', [], ['users' => ['user1', 'user2', 'user3']]); $this->endTest(); } @@ -182,17 +182,17 @@ class EncryptionTest extends TestCase { */ public function testGetPathToRealFile($path, $expected) { $this->assertSame($expected, - self::invokePrivate($this->instance, 'getPathToRealFile', array($path)) + self::invokePrivate($this->instance, 'getPathToRealFile', [$path]) ); } public function dataProviderForTestGetPathToRealFile() { - return array( - array('/user/files/foo/bar.txt', '/user/files/foo/bar.txt'), - array('/user/files/foo.txt', '/user/files/foo.txt'), - array('/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'), - array('/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'), - ); + return [ + ['/user/files/foo/bar.txt', '/user/files/foo/bar.txt'], + ['/user/files/foo.txt', '/user/files/foo.txt'], + ['/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'], + ['/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'], + ]; } /** @@ -241,12 +241,12 @@ class EncryptionTest extends TestCase { } public function dataTestBegin() { - return array( - array('w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'), - array('r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'), - array('w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'), - array('r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'), - ); + return [ + ['w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'], + ['r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'], + ['w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'], + ['r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'], + ]; } @@ -335,10 +335,10 @@ class EncryptionTest extends TestCase { } public function dataTestUpdate() { - return array( - array('', false), - array('fileKey', true) - ); + return [ + ['', false], + ['fileKey', true] + ]; } public function testUpdateNoUsers() { @@ -417,19 +417,19 @@ class EncryptionTest extends TestCase { } public function dataTestShouldEncrypt() { - return array( - array('/user1/files/foo.txt', true, true, true), - array('/user1/files_versions/foo.txt', true, true, true), - array('/user1/files_trashbin/foo.txt', true, true, true), - array('/user1/some_folder/foo.txt', true, true, false), - array('/user1/foo.txt', true, true, false), - array('/user1/files', true, true, false), - array('/user1/files_trashbin', true, true, false), - array('/user1/files_versions', true, true, false), + return [ + ['/user1/files/foo.txt', true, true, true], + ['/user1/files_versions/foo.txt', true, true, true], + ['/user1/files_trashbin/foo.txt', true, true, true], + ['/user1/some_folder/foo.txt', true, true, false], + ['/user1/foo.txt', true, true, false], + ['/user1/files', true, true, false], + ['/user1/files_trashbin', true, true, false], + ['/user1/files_versions', true, true, false], // test if shouldEncryptHomeStorage is set to false - array('/user1/files/foo.txt', false, true, false), - array('/user1/files_versions/foo.txt', false, false, true), - ); + ['/user1/files/foo.txt', false, true, false], + ['/user1/files_versions/foo.txt', false, false, true], + ]; } diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a9886a0b9ec..c7b9d62690e 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -322,7 +322,7 @@ class KeyManagerTest extends TestCase { $this->assertTrue( $this->instance->setRecoveryKey('pass', - array('publicKey' => 'publicKey', 'privateKey' => 'privateKey')) + ['publicKey' => 'publicKey', 'privateKey' => 'privateKey']) ); } @@ -505,12 +505,12 @@ class KeyManagerTest extends TestCase { * @return array */ public function dataTestAddSystemKeys() { - return array( - array(['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']), - array(['public' => false], [], 'user1', ['recoveryKey']), - array(['public' => true],[], 'user2', ['publicShareKey']), - array(['public' => false], [], 'user2', []), - ); + return [ + [['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']], + [['public' => false], [], 'user1', ['recoveryKey']], + [['public' => true],[], 'user2', ['publicShareKey']], + [['public' => false], [], 'user2', []], + ]; } public function testGetMasterKeyId() { |