From 266f16816ae2001d1e064535761b96e21da52fdc Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 15:11:04 -0600 Subject: [PATCH 1/9] enable unit tests for PHP 8 / PHPUnit 9 --- .travis.yml | 4 +- composer.json | 2 +- phpseclib/File/ANSI.php | 43 +++++++++--------- tests/Functional/Net/SCPSSH2UserStoryTest.php | 4 ++ tests/Functional/Net/SFTPLargeFileTest.php | 4 ++ tests/Functional/Net/SFTPStreamTest.php | 4 ++ tests/Functional/Net/SFTPUserStoryTest.php | 20 ++++----- tests/Functional/Net/SSH2AgentTest.php | 4 ++ tests/Functional/Net/SSH2Test.php | 6 ++- tests/PhpseclibTestCase.php | 44 +++++++++++++++++++ tests/Unit/Crypt/AES/McryptTest.php | 4 ++ tests/Unit/Crypt/AES/OpenSSLTest.php | 4 ++ .../AES/{InternalTest.php => PurePHPTest.php} | 6 ++- tests/Unit/Crypt/BlowfishTest.php | 4 ++ tests/Unit/Crypt/DESTest.php | 4 ++ tests/Unit/Crypt/Hash/MD5Test.php | 4 ++ tests/Unit/Crypt/Hash/SHA256Test.php | 4 ++ tests/Unit/Crypt/Hash/SHA256_96Test.php | 26 +++++++++++ tests/Unit/Crypt/Hash/SHA512Test.php | 4 ++ tests/Unit/Crypt/Hash/SHA512_96Test.php | 26 +++++++++++ tests/Unit/Crypt/RC2Test.php | 4 ++ tests/Unit/Crypt/RC4Test.php | 4 ++ tests/Unit/Crypt/RSA/LoadKeyTest.php | 28 +++++++----- tests/Unit/Crypt/RSA/ModeTest.php | 6 ++- tests/Unit/Crypt/RandomTest.php | 4 ++ tests/Unit/Crypt/TripleDESTest.php | 4 ++ tests/Unit/Crypt/TwofishTest.php | 4 ++ tests/Unit/File/ANSITest.php | 4 ++ tests/Unit/File/ASN1Test.php | 14 +++--- tests/Unit/File/X509/CSRTest.php | 10 +++-- tests/Unit/File/X509/SPKACTest.php | 18 +++++--- tests/Unit/File/X509/X509Test.php | 6 ++- tests/Unit/Math/BigInteger/BCMathTest.php | 4 ++ tests/Unit/Math/BigInteger/GMPTest.php | 4 ++ .../Math/BigInteger/InternalOpenSSLTest.php | 4 ++ tests/Unit/Math/BigInteger/InternalTest.php | 4 ++ tests/Unit/Math/BigInteger/TestCase.php | 2 +- ...PStreamTest.php => SFTPStreamUnitTest.php} | 6 ++- tests/Unit/Net/SSH1Test.php | 4 ++ .../Net/{SSH2Test.php => SSH2UnitTest.php} | 30 +++++++------ travis/run-phpunit.sh | 11 +++++ 41 files changed, 317 insertions(+), 79 deletions(-) rename tests/Unit/Crypt/AES/{InternalTest.php => PurePHPTest.php} (68%) rename tests/Unit/Net/{SFTPStreamTest.php => SFTPStreamUnitTest.php} (86%) rename tests/Unit/Net/{SSH2Test.php => SSH2UnitTest.php} (74%) diff --git a/.travis.yml b/.travis.yml index 6f7b22c4..b6a5d303 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,13 +22,15 @@ matrix: dist: xenial - php: 7.4 dist: xenial + - php: 8.0 + dist: bionic before_install: true install: - wget http://ftp.gnu.org/gnu/parallel/parallel-20170822.tar.bz2 - tar -xvjf parallel* - - cd parallel* + - cd parallel-20170822 - ./configure - make - sudo make install diff --git a/composer.json b/composer.json index 6729e8f9..9ff1f45b 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ }, "require-dev": { "phing/phing": "~2.7", - "phpunit/phpunit": "^4.8.35|^5.7|^6.0", + "phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4", "squizlabs/php_codesniffer": "~2.0" }, "suggest": { diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 51693be8..153bd443 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -342,19 +342,20 @@ class File_ANSI $mods = explode(';', $match[1]); foreach ($mods as $mod) { switch ($mod) { - case 0: // Turn off character attributes + case '': + case '0': // Turn off character attributes $attr_cell = clone($this->base_attr_cell); break; - case 1: // Turn bold mode on + case '1': // Turn bold mode on $attr_cell->bold = true; break; - case 4: // Turn underline mode on + case '4': // Turn underline mode on $attr_cell->underline = true; break; - case 5: // Turn blinking mode on + case '5': // Turn blinking mode on $attr_cell->blink = true; break; - case 7: // Turn reverse video on + case '7': // Turn reverse video on $attr_cell->reverse = !$attr_cell->reverse; $temp = $attr_cell->background; $attr_cell->background = $attr_cell->foreground; @@ -367,23 +368,23 @@ class File_ANSI $back = &$attr_cell->{ $attr_cell->reverse ? 'foreground' : 'background' }; switch ($mod) { // @codingStandardsIgnoreStart - case 30: $front = 'black'; break; - case 31: $front = 'red'; break; - case 32: $front = 'green'; break; - case 33: $front = 'yellow'; break; - case 34: $front = 'blue'; break; - case 35: $front = 'magenta'; break; - case 36: $front = 'cyan'; break; - case 37: $front = 'white'; break; + case '30': $front = 'black'; break; + case '31': $front = 'red'; break; + case '32': $front = 'green'; break; + case '33': $front = 'yellow'; break; + case '34': $front = 'blue'; break; + case '35': $front = 'magenta'; break; + case '36': $front = 'cyan'; break; + case '37': $front = 'white'; break; - case 40: $back = 'black'; break; - case 41: $back = 'red'; break; - case 42: $back = 'green'; break; - case 43: $back = 'yellow'; break; - case 44: $back = 'blue'; break; - case 45: $back = 'magenta'; break; - case 46: $back = 'cyan'; break; - case 47: $back = 'white'; break; + case '40': $back = 'black'; break; + case '41': $back = 'red'; break; + case '42': $back = 'green'; break; + case '43': $back = 'yellow'; break; + case '44': $back = 'blue'; break; + case '45': $back = 'magenta'; break; + case '46': $back = 'cyan'; break; + case '47': $back = 'white'; break; // @codingStandardsIgnoreEnd default: diff --git a/tests/Functional/Net/SCPSSH2UserStoryTest.php b/tests/Functional/Net/SCPSSH2UserStoryTest.php index 4ba69f14..3413fa42 100644 --- a/tests/Functional/Net/SCPSSH2UserStoryTest.php +++ b/tests/Functional/Net/SCPSSH2UserStoryTest.php @@ -86,3 +86,7 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase ); } } + +class SCPSSH2UserStoryTest extends Functional_Net_SCPSSH2UserStoryTest +{ +} diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index 0da85ab8..006adaf9 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -40,3 +40,7 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase ); } } + +class SFTPLargeFileTest extends Functional_Net_SFTPLargeFileTest +{ +} diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php index 55115603..fa10be9a 100644 --- a/tests/Functional/Net/SFTPStreamTest.php +++ b/tests/Functional/Net/SFTPStreamTest.php @@ -46,3 +46,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase ); } } + +class SFTPStreamTest extends Functional_Net_SFTPStreamTest +{ +} diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 8da91604..0470f475 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -133,7 +133,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase return $sftp; } - static function callback($length) + static function demoCallback($length) { $r = substr(self::$buffer, 0, $length); self::$buffer = substr(self::$buffer, $length); @@ -150,7 +150,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { self::$buffer = self::$exampleData; $this->assertTrue( - $sftp->put('file1.txt', array(__CLASS__, 'callback'), NET_SFTP_CALLBACK), + $sftp->put('file1.txt', array(__CLASS__, 'demoCallback'), NET_SFTP_CALLBACK), 'Failed asserting that example data could be successfully put().' ); @@ -437,8 +437,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase */ public function testReadlink($sftp) { - $this->assertInternalType( - 'string', + $this->assertIsString( $sftp->readlink('symlink'), 'Failed asserting that a symlink\'s target could be read' ); @@ -453,14 +452,12 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase public function testStatOnCWD($sftp) { $stat = $sftp->stat('.'); - $this->assertInternalType( - 'array', + $this->assertIsArray( $stat, 'Failed asserting that stat on . returns an array' ); $lstat = $sftp->lstat('.'); - $this->assertInternalType( - 'array', + $this->assertIsArray( $lstat, 'Failed asserting that lstat on . returns an array' ); @@ -602,8 +599,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase 'Failed asserting that scratch directory could ' . 'be created.' ); - $this->assertInternalType( - 'array', + $this->assertIsArray( $sftp->stat(self::$scratchDir), 'Failed asserting that stat on an existant empty directory returns an array' ); @@ -750,3 +746,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase $this->assertEquals($list_cache_enabled, $list_cache_disabled, 'The files should be the same regardless of stat cache', 0.0, 10, true); } } + +class SFTPUserStoryTest extends Functional_Net_SFTPUserStoryTest +{ +} diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index 7ba57d5c..7bee0594 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -50,3 +50,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase return $args; } } + +class SSH2AgentTest extends Functional_Net_SSH2AgentTest +{ +} diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index 872c8e78..cffb309b 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -122,7 +122,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase { $ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME')); - $this->assertInternalType('string', $ssh->getServerPublicHostKey()); + $this->assertIsString($ssh->getServerPublicHostKey()); } public function testOpenSocketConnect() @@ -170,3 +170,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase $ssh->read(); } } + +class SSH2Test extends Functional_Net_SSH2Test +{ +} diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php index a5344883..ca68596b 100644 --- a/tests/PhpseclibTestCase.php +++ b/tests/PhpseclibTestCase.php @@ -101,4 +101,48 @@ abstract class PhpseclibTestCase extends PHPUnit\Framework\TestCase } } } + + // assertIsArray was not introduced until PHPUnit 8 + public static function assertIsArray($actual, $message = '') + { + if (method_exists('\PHPUnit\Framework\TestCase', 'assertIsArray')) { + parent::assertIsArray($actual, $message); + return; + } + + parent::assertInternalType('array', $actual, $message); + } + + // assertIsString was not introduced until PHPUnit 8 + public static function assertIsString($actual, $message = '') + { + if (method_exists('\PHPUnit\Framework\TestCase', 'assertIsString')) { + parent::assertIsString($actual, $message); + return; + } + + parent::assertInternalType('string', $actual, $message); + } + + // assertContains is deprecated for strings in PHPUnit 8 + public static function assertStringContainsString($needle, $haystack, $message = '') + { + if (method_exists('\PHPUnit\Framework\TestCase', 'assertStringContainsString')) { + parent::assertStringContainsString($needle, $haystack, $message); + return; + } + + parent::assertContains($needle, $haystack, $message); + } + + // assertNotContains is deprecated for strings in PHPUnit 8 + public static function assertStringNotContainsString($needle, $haystack, $message = '') + { + if (method_exists('\PHPUnit\Framework\TestCase', 'assertStringContainsString')) { + parent::assertStringNotContainsString($needle, $haystack, $message); + return; + } + + parent::assertNotContains($needle, $haystack, $message); + } } diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index 41fa2041..633b1f73 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -12,3 +12,7 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase $this->engine = CRYPT_ENGINE_MCRYPT; } } + +class McryptTest extends Unit_Crypt_AES_McryptTest +{ +} diff --git a/tests/Unit/Crypt/AES/OpenSSLTest.php b/tests/Unit/Crypt/AES/OpenSSLTest.php index ddb5de67..dc8899ce 100644 --- a/tests/Unit/Crypt/AES/OpenSSLTest.php +++ b/tests/Unit/Crypt/AES/OpenSSLTest.php @@ -12,3 +12,7 @@ class Unit_Crypt_AES_OpenSSLTest extends Unit_Crypt_AES_TestCase $this->engine = CRYPT_ENGINE_OPENSSL; } } + +class OpenSSLTest extends Unit_Crypt_AES_OpenSSLTest +{ +} diff --git a/tests/Unit/Crypt/AES/InternalTest.php b/tests/Unit/Crypt/AES/PurePHPTest.php similarity index 68% rename from tests/Unit/Crypt/AES/InternalTest.php rename to tests/Unit/Crypt/AES/PurePHPTest.php index 75e89edf..2fe5d2c7 100644 --- a/tests/Unit/Crypt/AES/InternalTest.php +++ b/tests/Unit/Crypt/AES/PurePHPTest.php @@ -5,10 +5,14 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -class Unit_Crypt_AES_InternalTest extends Unit_Crypt_AES_TestCase +class Unit_Crypt_AES_PurePHPTest extends Unit_Crypt_AES_TestCase { protected function setUp() { $this->engine = CRYPT_ENGINE_INTERNAL; } } + +class PurePHPTest extends Unit_Crypt_AES_PurePHPTest +{ +} diff --git a/tests/Unit/Crypt/BlowfishTest.php b/tests/Unit/Crypt/BlowfishTest.php index 87406c13..014ff6a2 100644 --- a/tests/Unit/Crypt/BlowfishTest.php +++ b/tests/Unit/Crypt/BlowfishTest.php @@ -128,3 +128,7 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase } } } + +class BlowfishTest extends Unit_Crypt_BlowfishTest +{ +} diff --git a/tests/Unit/Crypt/DESTest.php b/tests/Unit/Crypt/DESTest.php index 2a51d6cf..b568fc2e 100644 --- a/tests/Unit/Crypt/DESTest.php +++ b/tests/Unit/Crypt/DESTest.php @@ -75,3 +75,7 @@ class Unit_Crypt_DESTest extends PhpseclibTestCase } } } + +class DESTest extends Unit_Crypt_DESTest +{ +} diff --git a/tests/Unit/Crypt/Hash/MD5Test.php b/tests/Unit/Crypt/Hash/MD5Test.php index a2969598..90f2f458 100644 --- a/tests/Unit/Crypt/Hash/MD5Test.php +++ b/tests/Unit/Crypt/Hash/MD5Test.php @@ -45,3 +45,7 @@ class Unit_Crypt_Hash_MD5Test extends Unit_Crypt_Hash_TestCase ); } } + +class MD5Test extends Unit_Crypt_Hash_MD5Test +{ +} diff --git a/tests/Unit/Crypt/Hash/SHA256Test.php b/tests/Unit/Crypt/Hash/SHA256Test.php index b4b1995a..488cf558 100644 --- a/tests/Unit/Crypt/Hash/SHA256Test.php +++ b/tests/Unit/Crypt/Hash/SHA256Test.php @@ -77,3 +77,7 @@ class Unit_Crypt_Hash_SHA256Test extends Unit_Crypt_Hash_TestCase ); } } + +class SHA256Test extends Unit_Crypt_Hash_SHA256Test +{ +} diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php index 3f2e1588..564aae94 100644 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA256_96Test.php @@ -5,6 +5,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +require_once 'SHA256Test.php'; + class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test { public function getInstance() @@ -28,3 +30,27 @@ class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test parent::testHMAC($key, $message, substr($longResult, 0, 24)); } } + +class SHA256_96Test extends SHA256Test +{ + public function getInstance() + { + return new Crypt_Hash('sha256-96'); + } + + /** + * @dataProvider hashData() + */ + public function testHash($message, $longResult) + { + parent::testHash($message, substr($longResult, 0, 24)); + } + + /** + * @dataProvider hmacData() + */ + public function testHMAC($key, $message, $longResult) + { + parent::testHMAC($key, $message, substr($longResult, 0, 24)); + } +} diff --git a/tests/Unit/Crypt/Hash/SHA512Test.php b/tests/Unit/Crypt/Hash/SHA512Test.php index 0a0e5818..cc1dce4f 100644 --- a/tests/Unit/Crypt/Hash/SHA512Test.php +++ b/tests/Unit/Crypt/Hash/SHA512Test.php @@ -77,3 +77,7 @@ class Unit_Crypt_Hash_SHA512Test extends Unit_Crypt_Hash_TestCase ); } } + +class SHA512Test extends Unit_Crypt_Hash_SHA512Test +{ +} diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php index bcf7b45b..caa4d49e 100644 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA512_96Test.php @@ -5,6 +5,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +require_once 'SHA512Test.php'; + class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test { public function getInstance() @@ -28,3 +30,27 @@ class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test parent::testHMAC($key, $message, substr($longResult, 0, 24)); } } + +class SHA512_96Test extends SHA512Test +{ + public function getInstance() + { + return new Crypt_Hash('sha512-96'); + } + + /** + * @dataProvider hashData() + */ + public function testHash($message, $longResult) + { + parent::testHash($message, substr($longResult, 0, 24)); + } + + /** + * @dataProvider hmacData() + */ + public function testHMAC($key, $message, $longResult) + { + parent::testHMAC($key, $message, substr($longResult, 0, 24)); + } +} diff --git a/tests/Unit/Crypt/RC2Test.php b/tests/Unit/Crypt/RC2Test.php index 0ad664bb..043b0605 100644 --- a/tests/Unit/Crypt/RC2Test.php +++ b/tests/Unit/Crypt/RC2Test.php @@ -125,3 +125,7 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase $this->assertEquals($result, $plaintext, "Failed asserting that decrypted result yielded $plaintext as a result in $engineName engine"); } } + +class RC2Test extends Unit_Crypt_RC2Test +{ +} diff --git a/tests/Unit/Crypt/RC4Test.php b/tests/Unit/Crypt/RC4Test.php index 4ba34e3d..4a956d31 100644 --- a/tests/Unit/Crypt/RC4Test.php +++ b/tests/Unit/Crypt/RC4Test.php @@ -248,3 +248,7 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase } } } + +class RC4Test extends Unit_Crypt_RC4Test +{ +} diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index f4dc544e..8d6af28c 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -require_once 'Crypt/RSA.php' ; +require_once 'Crypt/RSA.php'; class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase { @@ -37,7 +37,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ -----END RSA PRIVATE KEY-----'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testPKCS1SpacesKey() @@ -60,7 +60,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $key = str_replace(array("\r", "\n", "\r\n"), ' ', $key); $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testPKCS1NoHeaderKey() @@ -80,7 +80,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ 37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0='; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testPKCS1NoWhitespaceNoHeaderKey() @@ -100,7 +100,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0='; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testRawPKCS1Key() @@ -121,7 +121,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $key = base64_decode($key); $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testLoadPKCS8PrivateKey() @@ -160,7 +160,7 @@ xryZaRDVmtMuf/OZBQ== -----END ENCRYPTED PRIVATE KEY-----'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPrivateKey()); + $this->assertIsString($rsa->getPrivateKey()); } public function testSavePKCS8PrivateKey() @@ -185,7 +185,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertTrue($rsa->loadKey($key)); $key = $rsa->getPrivateKey(CRYPT_RSA_PRIVATE_FORMAT_PKCS8); - $this->assertInternalType('string', $key); + $this->assertIsString($key); $this->assertTrue($rsa->loadKey($key)); } @@ -204,7 +204,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB -----END RSA PUBLIC KEY-----'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPublicKey()); + $this->assertIsString($rsa->getPublicKey()); $this->assertFalse($rsa->getPrivateKey()); } @@ -223,7 +223,7 @@ ZQIDAQAB -----END PUBLIC KEY-----'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPublicKey()); + $this->assertIsString($rsa->getPublicKey()); $this->assertFalse($rsa->getPrivateKey()); } @@ -237,7 +237,7 @@ ZQIDAQAB 'phpseclib-generated-key'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPublicKey()); + $this->assertIsString($rsa->getPublicKey()); $this->assertFalse($rsa->getPrivateKey()); } @@ -415,7 +415,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB -----END RSA PUBLIC KEY-----'; $this->assertTrue($rsa->loadKey($key)); - $this->assertInternalType('string', $rsa->getPublicKey()); + $this->assertIsString($rsa->getPublicKey()); $this->assertFalse($rsa->loadKey('zzz')); $this->assertFalse($rsa->getPublicKey()); } @@ -478,3 +478,7 @@ Vyaqr/WTPzxdXJAAAADHJvb3RAdmFncmFudAECAwQFBg== $this->assertTrue($rsa->verify('zzz', $sig)); } } + +class LoadKeyTest extends Unit_Crypt_RSA_LoadKeyTest +{ +} diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index fce48110..eea8e0bf 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -require_once 'Crypt/RSA.php' ; +require_once 'Crypt/RSA.php'; class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase { @@ -116,3 +116,7 @@ k12yS6pCS3c+1wZ9cYFVtgfpSL4XpylLe9EnRT2GRVYCqUkR4AUeTuvnAgMBAAE= $this->assertTrue($rsa->verify($payload, $sig)); } } + +class ModeTest extends Unit_Crypt_RSA_ModeTest +{ +} diff --git a/tests/Unit/Crypt/RandomTest.php b/tests/Unit/Crypt/RandomTest.php index e53efc8d..94af2b39 100644 --- a/tests/Unit/Crypt/RandomTest.php +++ b/tests/Unit/Crypt/RandomTest.php @@ -51,3 +51,7 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase return array($x); } } + +class RandomTest extends Unit_Crypt_RandomTest +{ +} diff --git a/tests/Unit/Crypt/TripleDESTest.php b/tests/Unit/Crypt/TripleDESTest.php index c1f09ba1..8cdd4fa6 100644 --- a/tests/Unit/Crypt/TripleDESTest.php +++ b/tests/Unit/Crypt/TripleDESTest.php @@ -186,3 +186,7 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase } } } + +class TripleDESTest extends Unit_Crypt_TripleDESTest +{ +} diff --git a/tests/Unit/Crypt/TwofishTest.php b/tests/Unit/Crypt/TwofishTest.php index 53cfecd8..24a83a60 100644 --- a/tests/Unit/Crypt/TwofishTest.php +++ b/tests/Unit/Crypt/TwofishTest.php @@ -71,3 +71,7 @@ class Unit_Crypt_TwofishTest extends PhpseclibTestCase } } } + +class TwofishTest extends Unit_Crypt_TwofishTest +{ +} diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index 7fa89d7f..d64941bc 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -47,3 +47,7 @@ class Unit_File_ANSITest extends PhpseclibTestCase $this->assertSame(str_repeat('z', 80), $lines[22]); } } + +class ANSITest extends Unit_File_ANSITest +{ +} diff --git a/tests/Unit/File/ASN1Test.php b/tests/Unit/File/ASN1Test.php index 1864eff5..a28670a8 100644 --- a/tests/Unit/File/ASN1Test.php +++ b/tests/Unit/File/ASN1Test.php @@ -79,7 +79,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase $decoded = $asn1->decodeBER(base64_decode($str)); $result = $asn1->asn1map($decoded[0], $AS_REP); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); } /** @@ -231,7 +231,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase $decoded = $asn1->decodeBER(base64_decode($str)); $result = $asn1->asn1map($decoded[0], $AS_REP); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); } /** @@ -276,7 +276,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase { $asn1 = new File_ASN1(); $decoded = $asn1->decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv')); - $this->assertInternalType('string', $decoded[0]['content'][0]['content']); + $this->assertIsString($decoded[0]['content'][0]['content']); } /** @@ -286,7 +286,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase { $asn1 = new File_ASN1(); $decoded = $asn1->decodeBER("\xa0\x00"); - $this->assertInternalType('array', $decoded); + $this->assertIsArray($decoded); $this->assertCount(0, $decoded[0]['content']); } @@ -390,6 +390,10 @@ class Unit_File_ASN1Test extends PhpseclibTestCase $a = $asn1->decodeBER($a); $a = $asn1->asn1map($a[0], $map); - $this->assertInternalType('array', $a); + $this->assertIsArray($a); } } + +class ASN1Test extends Unit_File_ASN1Test +{ +} diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index fa86d356..84736641 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -27,7 +27,7 @@ v5RwaQHmQEzHofTzF7I+ $spkac = $x509->loadCSR($test); - $this->assertInternalType('array', $spkac); + $this->assertIsArray($spkac); } public function testCSRWithAttributes() @@ -67,7 +67,7 @@ draiRBZruwMPwPIP $csr = $x509->loadCSR($test); - $this->assertInternalType('array', $csr); + $this->assertIsArray($csr); } public function testCSRDER() @@ -92,7 +92,7 @@ draiRBZruwMPwPIP $csr = $x509->loadCSR($csr); - $this->assertInternalType('array', $csr); + $this->assertIsArray($csr); } // on PHP 7.1, with older versions of phpseclib, this would produce a "A non-numeric value encountered" warning @@ -119,3 +119,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $x509->saveCSR($x509->signCSR('sha256WithRSAEncryption'), FILE_X509_FORMAT_DER); } } + +class CSRTest extends Unit_File_X509_CSRTest +{ +} diff --git a/tests/Unit/File/X509/SPKACTest.php b/tests/Unit/File/X509/SPKACTest.php index 59bda3ae..2d7f0eca 100644 --- a/tests/Unit/File/X509/SPKACTest.php +++ b/tests/Unit/File/X509/SPKACTest.php @@ -28,11 +28,11 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase $spkac = $x509->loadSPKAC($test); - $this->assertInternalType('array', $spkac); + $this->assertIsArray($spkac); $spkac = $x509->loadSPKAC('SPKAC=' . $test); - $this->assertInternalType('array', $spkac); + $this->assertIsArray($spkac); $this->assertTrue( $x509->validateSignature(), @@ -41,7 +41,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase $pubKey = $x509->getPublicKey(); - $this->assertInternalType('string', "$pubKey"); + $this->assertIsString("$pubKey"); } public function testSaveSPKAC() @@ -55,17 +55,17 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase $x509->setChallenge('...'); $spkac = $x509->signSPKAC(); - $this->assertInternalType('array', $spkac); + $this->assertIsArray($spkac); - $this->assertInternalType('string', $x509->saveSPKAC($spkac)); + $this->assertIsString($x509->saveSPKAC($spkac)); $x509 = new File_X509(); $x509->setPrivateKey($privKey); $spkac = $x509->signSPKAC(); - $this->assertInternalType('array', $spkac); + $this->assertIsArray($spkac); - $this->assertInternalType('string', $x509->saveSPKAC($spkac)); + $this->assertIsString($x509->saveSPKAC($spkac)); } public function testBadSignatureSPKAC() @@ -96,3 +96,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase ); } } + +class SPKACTest extends Unit_File_X509_SPKACTest +{ +} diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index 8b86a637..2fb49e84 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -55,7 +55,7 @@ k6m17mi63YW/+iPCGOWZ2qXmY5HPEyyF2L4L4IDryFJ+8xLyw3pH9/yp5aHZDtp6 $cert = $x509->loadX509($test); - $this->assertInternalType('array', $cert['tbsCertificate']['extensions'][3]['extnValue']); + $this->assertIsArray($cert['tbsCertificate']['extensions'][3]['extnValue']); } public function testLoadUnsupportedExtension() @@ -856,3 +856,7 @@ mDaPrsUl15evEah6amsBfpQiWRbKpDLKs1kF $this->assertFalse($r); } } + +class X509Test extends Unit_File_X509_X509Test +{ +} diff --git a/tests/Unit/Math/BigInteger/BCMathTest.php b/tests/Unit/Math/BigInteger/BCMathTest.php index 109f81d0..b0305994 100644 --- a/tests/Unit/Math/BigInteger/BCMathTest.php +++ b/tests/Unit/Math/BigInteger/BCMathTest.php @@ -18,3 +18,7 @@ class Unit_Math_BigInteger_BCMathTest extends Unit_Math_BigInteger_TestCase self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); } } + +class BCMathTest extends Unit_Math_BigInteger_BCMathTest +{ +} diff --git a/tests/Unit/Math/BigInteger/GMPTest.php b/tests/Unit/Math/BigInteger/GMPTest.php index 2ec2042f..25ad8849 100644 --- a/tests/Unit/Math/BigInteger/GMPTest.php +++ b/tests/Unit/Math/BigInteger/GMPTest.php @@ -18,3 +18,7 @@ class Unit_Math_BigInteger_GMPTest extends Unit_Math_BigInteger_TestCase self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); } } + +class GMPTest extends Unit_Math_BigInteger_GMPTest +{ +} diff --git a/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php b/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php index 4b297d9f..21533b9c 100644 --- a/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php @@ -18,3 +18,7 @@ class Unit_Math_BigInteger_InternalOpenSSLTest extends Unit_Math_BigInteger_Test self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); } } + +class InternalOpenSSLTest extends Unit_Math_BigInteger_InternalOpenSSLTest +{ +} diff --git a/tests/Unit/Math/BigInteger/InternalTest.php b/tests/Unit/Math/BigInteger/InternalTest.php index f1fcae51..bbfe8ff0 100644 --- a/tests/Unit/Math/BigInteger/InternalTest.php +++ b/tests/Unit/Math/BigInteger/InternalTest.php @@ -22,3 +22,7 @@ class Unit_Math_BigInteger_InternalTest extends Unit_Math_BigInteger_TestCase $this->assertSame($x->value, $y->value); } } + +class InternalTest extends Unit_Math_BigInteger_InternalTest +{ +} diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index 6120bb86..1ccaae2f 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -402,7 +402,7 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase { $num = $this->getInstance(50); $str = print_r($num, true); - $this->assertContains('[value] => 0x32', $str); + $this->assertStringContainsString('[value] => 0x32', $str); return $str; } diff --git a/tests/Unit/Net/SFTPStreamTest.php b/tests/Unit/Net/SFTPStreamUnitTest.php similarity index 86% rename from tests/Unit/Net/SFTPStreamTest.php rename to tests/Unit/Net/SFTPStreamUnitTest.php index f5f83454..fc23ec3d 100644 --- a/tests/Unit/Net/SFTPStreamTest.php +++ b/tests/Unit/Net/SFTPStreamUnitTest.php @@ -7,7 +7,7 @@ require_once 'Net/SFTP/Stream.php'; -class Unit_Net_SFTPStreamTest extends PhpseclibTestCase +class Unit_Net_SFTPStreamUnitTest extends PhpseclibTestCase { protected $protocol = 'sftptest'; @@ -31,3 +31,7 @@ class Unit_Net_SFTPStreamTest extends PhpseclibTestCase $this->assertContains($this->protocol, stream_get_wrappers()); } } + +class SFTPStreamUnitTest extends Unit_Net_SFTPStreamUnitTest +{ +} diff --git a/tests/Unit/Net/SSH1Test.php b/tests/Unit/Net/SSH1Test.php index b0b2aaed..042cfe96 100644 --- a/tests/Unit/Net/SSH1Test.php +++ b/tests/Unit/Net/SSH1Test.php @@ -39,3 +39,7 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase $this->assertEquals($expected, $result); } } + +class SSH1Test extends Unit_Net_SSH1Test +{ +} diff --git a/tests/Unit/Net/SSH2Test.php b/tests/Unit/Net/SSH2UnitTest.php similarity index 74% rename from tests/Unit/Net/SSH2Test.php rename to tests/Unit/Net/SSH2UnitTest.php index e13b54a3..924b4bfe 100644 --- a/tests/Unit/Net/SSH2Test.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -6,7 +6,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -class Unit_Net_SSH2Test extends PhpseclibTestCase +class Unit_Net_SSH2UnitTest extends PhpseclibTestCase { public function formatLogDataProvider() { @@ -42,25 +42,25 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase $this->assertStringStartsWith('SSH-2.0-phpseclib_1.0', $identifier); if (extension_loaded('openssl')) { - $this->assertContains('openssl', $identifier); - $this->assertNotContains('mcrypt', $identifier); + $this->assertStringContainsString('openssl', $identifier); + $this->assertStringNotContainsString('mcrypt', $identifier); } elseif (extension_loaded('mcrypt')) { - $this->assertNotContains('openssl', $identifier); - $this->assertContains('mcrypt', $identifier); + $this->assertStringNotContainsString('openssl', $identifier); + $this->assertStringContainsString('mcrypt', $identifier); } else { - $this->assertNotContains('openssl', $identifier); - $this->assertNotContains('mcrypt', $identifier); + $this->assertStringNotContainsString('openssl', $identifier); + $this->assertStringNotContainsString('mcrypt', $identifier); } if (extension_loaded('gmp')) { - $this->assertContains('gmp', $identifier); - $this->assertNotContains('bcmath', $identifier); + $this->assertStringContainsString('gmp', $identifier); + $this->assertStringNotContainsString('bcmath', $identifier); } elseif (extension_loaded('bcmath')) { - $this->assertNotContains('gmp', $identifier); - $this->assertContains('bcmath', $identifier); + $this->assertStringNotContainsString('gmp', $identifier); + $this->assertStringContainsString('bcmath', $identifier); } else { - $this->assertNotContains('gmp', $identifier); - $this->assertNotContains('bcmath', $identifier); + $this->assertStringNotContainsString('gmp', $identifier); + $this->assertStringNotContainsString('bcmath', $identifier); } } @@ -117,3 +117,7 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase ->getMock(); } } + +class SSH2UnitTest extends Unit_Net_SSH2UnitTest +{ +} diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index ce393a77..2b1d90cc 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -20,6 +20,17 @@ then PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0" fi +if [ `php -r "echo (int) version_compare(PHP_VERSION, '7.3', '>=');"` = "1" ] +then + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUpBeforeClass()/n setUpBeforeClass(): void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUp()/n setUp(): void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n tearDown()/n tearDown(): void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsArray([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringContainsString([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringNotContainsString([^)]*)\)/\1: void/g' +fi + if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '>=');"` = "1" ] then find tests -type f -name "*Test.php" | \ From 245a84b57fd394533ccf92196378a4e21177b659 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 17:26:44 -0600 Subject: [PATCH 2/9] make unit tests pass without gnu parallel --- tests/Functional/Net/SFTPLargeFileTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index 006adaf9..2d02ff22 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -15,6 +15,7 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase if (!extension_loaded('mcrypt') && !extension_loaded('openssl')) { self::markTestSkipped('This test depends on mcrypt or openssl for performance.'); } + self::ensureConstant('CRYPT_HASH_MODE', 3); parent::setUpBeforeClass(); } From 95432478c0d56f096ab020e9abd25f675064d62d Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 17:15:52 -0600 Subject: [PATCH 3/9] fix bad merge --- build/code-sniffer-ruleset-tests.xml | 1 + tests/Functional/Net/SFTPUserStoryTest.php | 14 ++------------ tests/Unit/Crypt/Hash/SHA256_96Test.php | 2 +- tests/Unit/Crypt/Hash/SHA512_96Test.php | 2 +- tests/Unit/Crypt/RSA/LoadKeyTest.php | 5 ----- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/build/code-sniffer-ruleset-tests.xml b/build/code-sniffer-ruleset-tests.xml index 7169012e..17f00d1d 100644 --- a/build/code-sniffer-ruleset-tests.xml +++ b/build/code-sniffer-ruleset-tests.xml @@ -11,6 +11,7 @@ using underscore. --> + diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 0eec5ece..015fea03 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -151,7 +151,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase public function testPutSizeGetFile($sftp) { $this->assertTrue( - $sftp->put('file1.txt', array(__CLASS__, 'demoCallback'), NET_SFTP_CALLBACK), + $sftp->put('file1.txt', self::$exampleData), 'Failed asserting that example data could be successfully put().' ); @@ -170,16 +170,6 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase return $sftp; } - static function callback($length) - { - $r = substr(self::$buffer, 0, $length); - self::$buffer = substr(self::$buffer, $length); - if (strlen($r)) { - return $r; - } - return null; - } - /** * @depends testStatOnDir */ @@ -187,7 +177,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { self::$buffer = self::$exampleData; $this->assertTrue( - $sftp->put('file1.txt', array(__CLASS__, 'callback'), $sftp::SOURCE_CALLBACK), + $sftp->put('file1.txt', array(__CLASS__, 'demoCallback'), $sftp::SOURCE_CALLBACK), 'Failed asserting that example data could be successfully put().' ); diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php index e7a950cc..cc354b5d 100644 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA256_96Test.php @@ -35,7 +35,7 @@ class SHA256_96Test extends SHA256Test { public function getInstance() { - return new Crypt_Hash('sha256-96'); + return new Hash('sha256-96'); } /** diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php index 6ee9ede0..67f00ba2 100644 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA512_96Test.php @@ -35,7 +35,7 @@ class SHA512_96Test extends SHA512Test { public function getInstance() { - return new Crypt_Hash('sha512-96'); + return new Hash('sha512-96'); } /** diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 6bec9875..31c3e1c8 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -184,13 +184,8 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertTrue($rsa->loadKey($key)); -<<<<<<< HEAD $key = $rsa->getPrivateKey(RSA::PRIVATE_FORMAT_PKCS8); - $this->assertInternalType('string', $key); -======= - $key = $rsa->getPrivateKey(CRYPT_RSA_PRIVATE_FORMAT_PKCS8); $this->assertIsString($key); ->>>>>>> 1.0 $this->assertTrue($rsa->loadKey($key)); } From 7237c0f8034111d99a326246480ec3cff6c39d25 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 19:34:38 -0600 Subject: [PATCH 4/9] fix bad merge --- tests/Functional/Net/SSH2Test.php | 2 +- tests/Unit/Crypt/RSA/LoadKeyTest.php | 1 - tests/Unit/Math/BigInteger/PHP64Test.php | 2 +- travis/run-phpunit.sh | 2 ++ 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index 4b996b10..a5c437dd 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -14,7 +14,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); - $this->assertIsObject + $this->assertIsObject( $ssh, 'Could not construct NET_SSH2 object.' ); diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 2c04e2b3..c773d581 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -574,7 +574,6 @@ mKVKf5kPx2aR2W2KAcgw3TJIu1QX7N+l3kFrf9Owtz1a -----END ENCRYPTED PRIVATE KEY-----'; $pass = 'asdf'; -<<<<<<< HEAD $this->pkcs8tester($key, $pass); } diff --git a/tests/Unit/Math/BigInteger/PHP64Test.php b/tests/Unit/Math/BigInteger/PHP64Test.php index c44af643..13995a76 100644 --- a/tests/Unit/Math/BigInteger/PHP64Test.php +++ b/tests/Unit/Math/BigInteger/PHP64Test.php @@ -36,6 +36,6 @@ class Unit_Math_BigInteger_PHP64Test extends Unit_Math_BigInteger_TestCase } } -classs PHP64Test extends Unit_Math_BigInteger_PHP64Test +class PHP64Test extends Unit_Math_BigInteger_PHP64Test { } diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 2b1d90cc..7e79c46e 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -27,6 +27,8 @@ then find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n tearDown()/n tearDown(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsArray([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsResource([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsObject([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringContainsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringNotContainsString([^)]*)\)/\1: void/g' fi From 1a30cd862ff27a7b634e14f2d9828211a88ee4da Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 20:13:42 -0600 Subject: [PATCH 5/9] ... --- tests/Unit/Crypt/DSA/LoadDSAKeyTest.php | 15 +++++++++++++++ tests/Unit/Crypt/HashTest.php | 15 +++++++++++++++ tests/Unit/Crypt/RSA/LoadKeyTest.php | 15 +++++++++++++++ tests/Unit/Crypt/RSA/ModeTest.php | 7 +++++++ tests/Unit/Net/SSH2UnitTest.php | 2 +- travis/run-phpunit.sh | 1 + 6 files changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php index 0c681658..d04112b6 100644 --- a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php +++ b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php @@ -259,4 +259,19 @@ dlN48qLbSmUgsO7gq/1vodebMSHcduV4JTq8ix5Ey87QAAABQhHEzWiduF4V0DestSnJ3q class LoadDSAKeyTest extends Unit_Crypt_DSA_LoadDSAKeyTest { + /** + * @expectedException \phpseclib3\Exception\NoKeyLoadedException + */ + public function testBadKey() + { + parent::testBadKey(); + } + + /** + * @expectedException \phpseclib3\Exception\NoKeyLoadedException + */ + public function testPuTTYBadMAC() + { + parent::testPuTTYBadMac(); + } } diff --git a/tests/Unit/Crypt/HashTest.php b/tests/Unit/Crypt/HashTest.php index 0ef81c92..204169b5 100644 --- a/tests/Unit/Crypt/HashTest.php +++ b/tests/Unit/Crypt/HashTest.php @@ -468,4 +468,19 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase class HashTest extends Unit_Crypt_HashTest { + /** + * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException + */ + public function testConstructorArgumentInvalid() + { + parent::testConstructorArgumentInvalid(); + } + + /** + * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException + */ + public function testSetHashInvalid() + { + parent::testSetHashInvalid(); + } } diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index c773d581..1788513a 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -1049,4 +1049,19 @@ n9dyFZYXxil/cgFG/PDMnuXy1Wcl8hb8iwQag4Y7ohiLXVTJa/0BAgMBAAE= class LoadKeyTest extends Unit_Crypt_RSA_LoadKeyTest { + /** + * @expectedException \phpseclib3\Exception\NoKeyLoadedException + */ + public function testBadKey() + { + parent::testBadKey(); + } + + /** + * @expectedException \phpseclib3\Exception\UnsupportedFormatException + */ + public function testSavePasswordXML() + { + parent::testSavePasswordXML(); + } } diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index b252f799..972892b1 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -187,4 +187,11 @@ HERE; class ModeTest extends Unit_Crypt_RSA_ModeTest { + /** + * @expectedException \LengthException + */ + public function testSmallModulo() + { + parent::testSmallModulo(); + } } diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index ad599106..2d2db708 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -42,7 +42,7 @@ class Unit_Net_SSH2UnitTest extends PhpseclibTestCase $this->assertStringStartsWith('SSH-2.0-phpseclib_3.0', $identifier); if (function_exists('sodium_crypto_sign_keypair')) { - $this->assertContains('libsodium', $identifier); + $this->assertStringContainsString('libsodium', $identifier); } if (extension_loaded('openssl')) { diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 7e79c46e..3e49318b 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -25,6 +25,7 @@ then find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUpBeforeClass()/n setUpBeforeClass(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUp()/n setUp(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n tearDown()/n tearDown(): void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n assertSame()/n assertSame(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsArray([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsResource([^)]*)\)/\1: void/g' From e6abc61f45b3121f545ac05271deac209ecdef11 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 20:39:56 -0600 Subject: [PATCH 6/9] rm adding of dupe classes (they break annotations) --- tests/Functional/Net/SCPSSH2UserStoryTest.php | 4 ---- tests/Functional/Net/SFTPLargeFileTest.php | 4 ---- tests/Functional/Net/SFTPStreamTest.php | 4 ---- tests/Functional/Net/SFTPUserStoryTest.php | 4 ---- tests/Functional/Net/SSH2AgentTest.php | 4 ---- tests/Functional/Net/SSH2Test.php | 4 ---- tests/Unit/Crypt/AES/McryptTest.php | 4 ---- tests/Unit/Crypt/AES/OpenSSLTest.php | 4 ---- tests/Unit/Crypt/AES/PurePHPTest.php | 4 ---- tests/Unit/Crypt/BlowfishTest.php | 4 ---- tests/Unit/Crypt/DESTest.php | 4 ---- tests/Unit/Crypt/Hash/MD5Test.php | 4 ---- tests/Unit/Crypt/Hash/SHA256Test.php | 4 ---- tests/Unit/Crypt/Hash/SHA256_96Test.php | 24 ------------------- tests/Unit/Crypt/Hash/SHA512Test.php | 4 ---- tests/Unit/Crypt/Hash/SHA512_96Test.php | 24 ------------------- tests/Unit/Crypt/RC2Test.php | 4 ---- tests/Unit/Crypt/RC4Test.php | 4 ---- tests/Unit/Crypt/RSA/LoadKeyTest.php | 4 ---- tests/Unit/Crypt/RSA/ModeTest.php | 4 ---- tests/Unit/Crypt/RandomTest.php | 4 ---- tests/Unit/Crypt/TripleDESTest.php | 4 ---- tests/Unit/Crypt/TwofishTest.php | 4 ---- tests/Unit/File/ANSITest.php | 4 ---- tests/Unit/File/ASN1Test.php | 4 ---- tests/Unit/File/X509/CSRTest.php | 4 ---- tests/Unit/File/X509/SPKACTest.php | 4 ---- tests/Unit/File/X509/X509Test.php | 4 ---- tests/Unit/Math/BigInteger/BCMathTest.php | 4 ---- tests/Unit/Math/BigInteger/GMPTest.php | 4 ---- .../Math/BigInteger/InternalOpenSSLTest.php | 4 ---- tests/Unit/Math/BigInteger/InternalTest.php | 4 ---- tests/Unit/Net/SFTPStreamUnitTest.php | 4 ---- tests/Unit/Net/SSH1Test.php | 4 ---- tests/Unit/Net/SSH2UnitTest.php | 4 ---- travis/run-phpunit.sh | 6 +++++ 36 files changed, 6 insertions(+), 180 deletions(-) diff --git a/tests/Functional/Net/SCPSSH2UserStoryTest.php b/tests/Functional/Net/SCPSSH2UserStoryTest.php index 3413fa42..4ba69f14 100644 --- a/tests/Functional/Net/SCPSSH2UserStoryTest.php +++ b/tests/Functional/Net/SCPSSH2UserStoryTest.php @@ -86,7 +86,3 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase ); } } - -class SCPSSH2UserStoryTest extends Functional_Net_SCPSSH2UserStoryTest -{ -} diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index 2d02ff22..36115d54 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -41,7 +41,3 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase ); } } - -class SFTPLargeFileTest extends Functional_Net_SFTPLargeFileTest -{ -} diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php index fa10be9a..55115603 100644 --- a/tests/Functional/Net/SFTPStreamTest.php +++ b/tests/Functional/Net/SFTPStreamTest.php @@ -46,7 +46,3 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase ); } } - -class SFTPStreamTest extends Functional_Net_SFTPStreamTest -{ -} diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 0470f475..6787b62f 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -746,7 +746,3 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase $this->assertEquals($list_cache_enabled, $list_cache_disabled, 'The files should be the same regardless of stat cache', 0.0, 10, true); } } - -class SFTPUserStoryTest extends Functional_Net_SFTPUserStoryTest -{ -} diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index 7bee0594..7ba57d5c 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -50,7 +50,3 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase return $args; } } - -class SSH2AgentTest extends Functional_Net_SSH2AgentTest -{ -} diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index cffb309b..09c9ff04 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -170,7 +170,3 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase $ssh->read(); } } - -class SSH2Test extends Functional_Net_SSH2Test -{ -} diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index 633b1f73..41fa2041 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -12,7 +12,3 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase $this->engine = CRYPT_ENGINE_MCRYPT; } } - -class McryptTest extends Unit_Crypt_AES_McryptTest -{ -} diff --git a/tests/Unit/Crypt/AES/OpenSSLTest.php b/tests/Unit/Crypt/AES/OpenSSLTest.php index dc8899ce..ddb5de67 100644 --- a/tests/Unit/Crypt/AES/OpenSSLTest.php +++ b/tests/Unit/Crypt/AES/OpenSSLTest.php @@ -12,7 +12,3 @@ class Unit_Crypt_AES_OpenSSLTest extends Unit_Crypt_AES_TestCase $this->engine = CRYPT_ENGINE_OPENSSL; } } - -class OpenSSLTest extends Unit_Crypt_AES_OpenSSLTest -{ -} diff --git a/tests/Unit/Crypt/AES/PurePHPTest.php b/tests/Unit/Crypt/AES/PurePHPTest.php index 2fe5d2c7..12161a9d 100644 --- a/tests/Unit/Crypt/AES/PurePHPTest.php +++ b/tests/Unit/Crypt/AES/PurePHPTest.php @@ -12,7 +12,3 @@ class Unit_Crypt_AES_PurePHPTest extends Unit_Crypt_AES_TestCase $this->engine = CRYPT_ENGINE_INTERNAL; } } - -class PurePHPTest extends Unit_Crypt_AES_PurePHPTest -{ -} diff --git a/tests/Unit/Crypt/BlowfishTest.php b/tests/Unit/Crypt/BlowfishTest.php index 014ff6a2..87406c13 100644 --- a/tests/Unit/Crypt/BlowfishTest.php +++ b/tests/Unit/Crypt/BlowfishTest.php @@ -128,7 +128,3 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase } } } - -class BlowfishTest extends Unit_Crypt_BlowfishTest -{ -} diff --git a/tests/Unit/Crypt/DESTest.php b/tests/Unit/Crypt/DESTest.php index b568fc2e..2a51d6cf 100644 --- a/tests/Unit/Crypt/DESTest.php +++ b/tests/Unit/Crypt/DESTest.php @@ -75,7 +75,3 @@ class Unit_Crypt_DESTest extends PhpseclibTestCase } } } - -class DESTest extends Unit_Crypt_DESTest -{ -} diff --git a/tests/Unit/Crypt/Hash/MD5Test.php b/tests/Unit/Crypt/Hash/MD5Test.php index 90f2f458..a2969598 100644 --- a/tests/Unit/Crypt/Hash/MD5Test.php +++ b/tests/Unit/Crypt/Hash/MD5Test.php @@ -45,7 +45,3 @@ class Unit_Crypt_Hash_MD5Test extends Unit_Crypt_Hash_TestCase ); } } - -class MD5Test extends Unit_Crypt_Hash_MD5Test -{ -} diff --git a/tests/Unit/Crypt/Hash/SHA256Test.php b/tests/Unit/Crypt/Hash/SHA256Test.php index 488cf558..b4b1995a 100644 --- a/tests/Unit/Crypt/Hash/SHA256Test.php +++ b/tests/Unit/Crypt/Hash/SHA256Test.php @@ -77,7 +77,3 @@ class Unit_Crypt_Hash_SHA256Test extends Unit_Crypt_Hash_TestCase ); } } - -class SHA256Test extends Unit_Crypt_Hash_SHA256Test -{ -} diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php index 564aae94..5e1f1139 100644 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA256_96Test.php @@ -30,27 +30,3 @@ class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test parent::testHMAC($key, $message, substr($longResult, 0, 24)); } } - -class SHA256_96Test extends SHA256Test -{ - public function getInstance() - { - return new Crypt_Hash('sha256-96'); - } - - /** - * @dataProvider hashData() - */ - public function testHash($message, $longResult) - { - parent::testHash($message, substr($longResult, 0, 24)); - } - - /** - * @dataProvider hmacData() - */ - public function testHMAC($key, $message, $longResult) - { - parent::testHMAC($key, $message, substr($longResult, 0, 24)); - } -} diff --git a/tests/Unit/Crypt/Hash/SHA512Test.php b/tests/Unit/Crypt/Hash/SHA512Test.php index cc1dce4f..0a0e5818 100644 --- a/tests/Unit/Crypt/Hash/SHA512Test.php +++ b/tests/Unit/Crypt/Hash/SHA512Test.php @@ -77,7 +77,3 @@ class Unit_Crypt_Hash_SHA512Test extends Unit_Crypt_Hash_TestCase ); } } - -class SHA512Test extends Unit_Crypt_Hash_SHA512Test -{ -} diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php index caa4d49e..f5cdce88 100644 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA512_96Test.php @@ -30,27 +30,3 @@ class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test parent::testHMAC($key, $message, substr($longResult, 0, 24)); } } - -class SHA512_96Test extends SHA512Test -{ - public function getInstance() - { - return new Crypt_Hash('sha512-96'); - } - - /** - * @dataProvider hashData() - */ - public function testHash($message, $longResult) - { - parent::testHash($message, substr($longResult, 0, 24)); - } - - /** - * @dataProvider hmacData() - */ - public function testHMAC($key, $message, $longResult) - { - parent::testHMAC($key, $message, substr($longResult, 0, 24)); - } -} diff --git a/tests/Unit/Crypt/RC2Test.php b/tests/Unit/Crypt/RC2Test.php index 043b0605..0ad664bb 100644 --- a/tests/Unit/Crypt/RC2Test.php +++ b/tests/Unit/Crypt/RC2Test.php @@ -125,7 +125,3 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase $this->assertEquals($result, $plaintext, "Failed asserting that decrypted result yielded $plaintext as a result in $engineName engine"); } } - -class RC2Test extends Unit_Crypt_RC2Test -{ -} diff --git a/tests/Unit/Crypt/RC4Test.php b/tests/Unit/Crypt/RC4Test.php index 4a956d31..4ba34e3d 100644 --- a/tests/Unit/Crypt/RC4Test.php +++ b/tests/Unit/Crypt/RC4Test.php @@ -248,7 +248,3 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase } } } - -class RC4Test extends Unit_Crypt_RC4Test -{ -} diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 8d6af28c..18a93619 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -478,7 +478,3 @@ Vyaqr/WTPzxdXJAAAADHJvb3RAdmFncmFudAECAwQFBg== $this->assertTrue($rsa->verify('zzz', $sig)); } } - -class LoadKeyTest extends Unit_Crypt_RSA_LoadKeyTest -{ -} diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index eea8e0bf..28e91643 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -116,7 +116,3 @@ k12yS6pCS3c+1wZ9cYFVtgfpSL4XpylLe9EnRT2GRVYCqUkR4AUeTuvnAgMBAAE= $this->assertTrue($rsa->verify($payload, $sig)); } } - -class ModeTest extends Unit_Crypt_RSA_ModeTest -{ -} diff --git a/tests/Unit/Crypt/RandomTest.php b/tests/Unit/Crypt/RandomTest.php index 94af2b39..e53efc8d 100644 --- a/tests/Unit/Crypt/RandomTest.php +++ b/tests/Unit/Crypt/RandomTest.php @@ -51,7 +51,3 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase return array($x); } } - -class RandomTest extends Unit_Crypt_RandomTest -{ -} diff --git a/tests/Unit/Crypt/TripleDESTest.php b/tests/Unit/Crypt/TripleDESTest.php index 8cdd4fa6..c1f09ba1 100644 --- a/tests/Unit/Crypt/TripleDESTest.php +++ b/tests/Unit/Crypt/TripleDESTest.php @@ -186,7 +186,3 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase } } } - -class TripleDESTest extends Unit_Crypt_TripleDESTest -{ -} diff --git a/tests/Unit/Crypt/TwofishTest.php b/tests/Unit/Crypt/TwofishTest.php index 24a83a60..53cfecd8 100644 --- a/tests/Unit/Crypt/TwofishTest.php +++ b/tests/Unit/Crypt/TwofishTest.php @@ -71,7 +71,3 @@ class Unit_Crypt_TwofishTest extends PhpseclibTestCase } } } - -class TwofishTest extends Unit_Crypt_TwofishTest -{ -} diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index d64941bc..7fa89d7f 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -47,7 +47,3 @@ class Unit_File_ANSITest extends PhpseclibTestCase $this->assertSame(str_repeat('z', 80), $lines[22]); } } - -class ANSITest extends Unit_File_ANSITest -{ -} diff --git a/tests/Unit/File/ASN1Test.php b/tests/Unit/File/ASN1Test.php index a28670a8..00ee7c8e 100644 --- a/tests/Unit/File/ASN1Test.php +++ b/tests/Unit/File/ASN1Test.php @@ -393,7 +393,3 @@ class Unit_File_ASN1Test extends PhpseclibTestCase $this->assertIsArray($a); } } - -class ASN1Test extends Unit_File_ASN1Test -{ -} diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index 84736641..f57a0e6d 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -119,7 +119,3 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $x509->saveCSR($x509->signCSR('sha256WithRSAEncryption'), FILE_X509_FORMAT_DER); } } - -class CSRTest extends Unit_File_X509_CSRTest -{ -} diff --git a/tests/Unit/File/X509/SPKACTest.php b/tests/Unit/File/X509/SPKACTest.php index 2d7f0eca..1345f45e 100644 --- a/tests/Unit/File/X509/SPKACTest.php +++ b/tests/Unit/File/X509/SPKACTest.php @@ -96,7 +96,3 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase ); } } - -class SPKACTest extends Unit_File_X509_SPKACTest -{ -} diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index 2fb49e84..9f5eeba9 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -856,7 +856,3 @@ mDaPrsUl15evEah6amsBfpQiWRbKpDLKs1kF $this->assertFalse($r); } } - -class X509Test extends Unit_File_X509_X509Test -{ -} diff --git a/tests/Unit/Math/BigInteger/BCMathTest.php b/tests/Unit/Math/BigInteger/BCMathTest.php index b0305994..109f81d0 100644 --- a/tests/Unit/Math/BigInteger/BCMathTest.php +++ b/tests/Unit/Math/BigInteger/BCMathTest.php @@ -18,7 +18,3 @@ class Unit_Math_BigInteger_BCMathTest extends Unit_Math_BigInteger_TestCase self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); } } - -class BCMathTest extends Unit_Math_BigInteger_BCMathTest -{ -} diff --git a/tests/Unit/Math/BigInteger/GMPTest.php b/tests/Unit/Math/BigInteger/GMPTest.php index 25ad8849..2ec2042f 100644 --- a/tests/Unit/Math/BigInteger/GMPTest.php +++ b/tests/Unit/Math/BigInteger/GMPTest.php @@ -18,7 +18,3 @@ class Unit_Math_BigInteger_GMPTest extends Unit_Math_BigInteger_TestCase self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); } } - -class GMPTest extends Unit_Math_BigInteger_GMPTest -{ -} diff --git a/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php b/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php index 21533b9c..4b297d9f 100644 --- a/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/InternalOpenSSLTest.php @@ -18,7 +18,3 @@ class Unit_Math_BigInteger_InternalOpenSSLTest extends Unit_Math_BigInteger_Test self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); } } - -class InternalOpenSSLTest extends Unit_Math_BigInteger_InternalOpenSSLTest -{ -} diff --git a/tests/Unit/Math/BigInteger/InternalTest.php b/tests/Unit/Math/BigInteger/InternalTest.php index bbfe8ff0..f1fcae51 100644 --- a/tests/Unit/Math/BigInteger/InternalTest.php +++ b/tests/Unit/Math/BigInteger/InternalTest.php @@ -22,7 +22,3 @@ class Unit_Math_BigInteger_InternalTest extends Unit_Math_BigInteger_TestCase $this->assertSame($x->value, $y->value); } } - -class InternalTest extends Unit_Math_BigInteger_InternalTest -{ -} diff --git a/tests/Unit/Net/SFTPStreamUnitTest.php b/tests/Unit/Net/SFTPStreamUnitTest.php index fc23ec3d..663db6d9 100644 --- a/tests/Unit/Net/SFTPStreamUnitTest.php +++ b/tests/Unit/Net/SFTPStreamUnitTest.php @@ -31,7 +31,3 @@ class Unit_Net_SFTPStreamUnitTest extends PhpseclibTestCase $this->assertContains($this->protocol, stream_get_wrappers()); } } - -class SFTPStreamUnitTest extends Unit_Net_SFTPStreamUnitTest -{ -} diff --git a/tests/Unit/Net/SSH1Test.php b/tests/Unit/Net/SSH1Test.php index 042cfe96..b0b2aaed 100644 --- a/tests/Unit/Net/SSH1Test.php +++ b/tests/Unit/Net/SSH1Test.php @@ -39,7 +39,3 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase $this->assertEquals($expected, $result); } } - -class SSH1Test extends Unit_Net_SSH1Test -{ -} diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 924b4bfe..1c8436b9 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -117,7 +117,3 @@ class Unit_Net_SSH2UnitTest extends PhpseclibTestCase ->getMock(); } } - -class SSH2UnitTest extends Unit_Net_SSH2UnitTest -{ -} diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 2b1d90cc..92351bb2 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -29,6 +29,12 @@ then find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringContainsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringNotContainsString([^)]*)\)/\1: void/g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Crypt_\(AES\|Hash\|RSA\)_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_File_\(X509\)_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Math_\(BigInteger\)_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_\(Crypt\|File\|Math\|Net\)_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Functional_Net_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/extends Unit_Crypt_Hash_\(SHA512Test\|SHA256Test\)/extends \1/g' fi if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '>=');"` = "1" ] From 360afd93c80449e6c5dd70856c6fd83ad2a64805 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 22:02:16 -0600 Subject: [PATCH 7/9] fix bad merge --- tests/Unit/Crypt/Hash/SHA256_96Test.php | 4 ++++ tests/Unit/Crypt/Hash/SHA512_96Test.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php index 85aaf295..24a09be4 100644 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA256_96Test.php @@ -7,6 +7,10 @@ use phpseclib\Crypt\Hash; +if (version_compare(PHP_VERSION, '7.0', '>=')) { + require 'SHA256Test.php'; +} + class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test { public function getInstance() diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php index 760fa243..0d48a7fb 100644 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA512_96Test.php @@ -7,6 +7,10 @@ use phpseclib\Crypt\Hash; +if (version_compare(PHP_VERSION, '7.0', '>=')) { + require 'SHA512Test.php'; +} + class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test { public function getInstance() From 61d885630f75e168fa738feed5ff88c35152f311 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 22:32:46 -0600 Subject: [PATCH 8/9] CS adjustment --- build/code-sniffer-ruleset-tests.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/code-sniffer-ruleset-tests.xml b/build/code-sniffer-ruleset-tests.xml index 17f00d1d..8767eee9 100644 --- a/build/code-sniffer-ruleset-tests.xml +++ b/build/code-sniffer-ruleset-tests.xml @@ -11,7 +11,7 @@ using underscore. --> - + From c5d9534ada9433fa493afae0d99d24be2e7066ab Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 12 Dec 2020 22:47:25 -0600 Subject: [PATCH 9/9] fix bad merge --- composer.json | 2 +- tests/Unit/Crypt/AES/TestCase.php | 20 ++-- tests/Unit/Crypt/DSA/LoadDSAKeyTest.php | 11 +- tests/Unit/Crypt/EC/KeyTest.php | 108 +++++++++--------- tests/Unit/Crypt/HashTest.php | 30 +---- tests/Unit/Crypt/RSA/LoadKeyTest.php | 12 +- tests/Unit/Crypt/RSA/ModeTest.php | 5 +- .../Unit/Math/BigInteger/PHP64OpenSSLTest.php | 24 +++- travis/run-phpunit.sh | 4 +- 9 files changed, 106 insertions(+), 110 deletions(-) diff --git a/composer.json b/composer.json index 887639d1..9a0451ff 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ } ], "require": { - "paragonie/constant_time_encoding": "^1", + "paragonie/constant_time_encoding": "^1|^2", "paragonie/random_compat": "^1.4|^2.0", "php": ">=5.6.1" }, diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index f884ae4c..3fbca424 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -8,6 +8,8 @@ use phpseclib3\Crypt\AES; use phpseclib3\Crypt\Common\BlockCipher; use phpseclib3\Crypt\Rijndael; +use phpseclib3\Exception\InconsistentSetupException; +use phpseclib3\Exception\InsufficientSetupException; abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase { @@ -105,10 +107,11 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase /** * @group github451 - * @expectedException \LengthException */ public function testKeyPaddingAES() { + $this->expectException('LengthException'); + // same as the above - just with a different ciphertext $aes = new AES('cbc'); @@ -347,11 +350,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $this->assertSame($aes->getKeyLength(), 192); } - /** - * @expectedException \phpseclib3\Exception\InconsistentSetupException - */ public function testSetKeyLengthWithLargerKey() { + $this->expectException(InconsistentSetupException::class); + $aes = new AES('cbc'); $aes->setKeyLength(128); $aes->setKey(str_repeat('a', 24)); @@ -362,11 +364,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $this->assertSame($aes->getKeyLength(), 128); } - /** - * @expectedException \phpseclib3\Exception\InconsistentSetupException - */ public function testSetKeyLengthWithSmallerKey() { + $this->expectException(InconsistentSetupException::class); + $aes = new AES('cbc'); $aes->setKeyLength(256); $aes->setKey(str_repeat('a', 16)); @@ -408,11 +409,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $this->assertEquals($plaintext, $actual); } - /** - * @expectedException \phpseclib3\Exception\InsufficientSetupException - */ public function testNoKey() { + $this->expectException(InsufficientSetupException::class); + $aes = new AES('cbc'); $aes->setPreferredEngine($this->engine); $aes->setIV(str_repeat('x', 16)); diff --git a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php index 29b16693..d981136e 100644 --- a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php +++ b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php @@ -13,14 +13,14 @@ use phpseclib3\Crypt\DSA\Formats\Keys\PKCS1; use phpseclib3\Crypt\DSA\Formats\Keys\PKCS8; use phpseclib3\Crypt\DSA\Formats\Keys\PuTTY; use phpseclib3\Math\BigInteger; +use phpseclib3\Exception\NoKeyLoadedException; class Unit_Crypt_DSA_LoadDSAKeyTest extends PhpseclibTestCase { - /** - * @expectedException \phpseclib3\Exception\NoKeyLoadedException - */ public function testBadKey() { + $this->expectException(NoKeyLoadedException::class); + $key = 'zzzzzzzzzzzzzz'; PublicKeyLoader::load($key); } @@ -156,11 +156,10 @@ Syea3pSvWdBpVhWzOX4A7qbxs+bhWAQWAhQiF7sFfCtZ7oOgCb2aJ9ySC9sTug== $this->assertInstanceOf(Parameters::class, $dsa->getParameters()); } - /** - * @expectedException \phpseclib3\Exception\NoKeyLoadedException - */ public function testPuTTYBadMAC() { + $this->expectException(NoKeyLoadedException::class); + $key = 'PuTTY-User-Key-File-2: ssh-dss Encryption: none Comment: dsa-key-20161223 diff --git a/tests/Unit/Crypt/EC/KeyTest.php b/tests/Unit/Crypt/EC/KeyTest.php index c9d642d5..7d72102c 100644 --- a/tests/Unit/Crypt/EC/KeyTest.php +++ b/tests/Unit/Crypt/EC/KeyTest.php @@ -27,7 +27,7 @@ Stf/0U65RhWgBwYFK4EEACKhZANiAASVZJGIs6m/TZhbFoTwBtpvU1JcyixD2YI3 5YnoIx/6Q1oqJg1vrrmUoXaeEpaO6JH8RgItTl9lYMdmOk5309WJka6tI1QAAK3+ Jq9z4moG4whp3JsuiBQG9wnaHVrQPA4= -----END EC PRIVATE KEY-----'); - $this->assertSame('secp384r1', $key->getCurve()); + $this->assertSameNL('secp384r1', $key->getCurve()); } // openssl ecparam -name secp256k1 -genkey -noout -out secp256k1.pem @@ -38,9 +38,9 @@ MHQCAQEEIEzUawcXqUsQhaEQ51JLeOIY0ddzlO2nNgwDk32ETqwkoAcGBSuBBAAK oUQDQgAEFuVcVb9iCUhg2cknHPE+BouHGhQ39ORjMaMI3T4RfRxr6dj5HAXdEqVZ 1W94KMe30ndmTndcJ8BPeT1Dd15FdQ== -----END EC PRIVATE KEY-----'); - $this->assertSame('secp256k1', $key->getCurve()); + $this->assertSameNL('secp256k1', $key->getCurve()); //PKCS1::useNamedCurve(); - $this->assertSame($expected, $key->toString('PKCS1')); + $this->assertSameNL($expected, $key->toString('PKCS1')); } // openssl ecparam -name secp256k1 -genkey -noout -out secp256k1.pem -param_enc explicit @@ -54,7 +54,7 @@ o8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA/////////////////////rqu 3OavSKA7v9JejNA2QUECAQGhRANCAASCTRhjXqmdbqphSdxNkfTNAOmDW5cZ5fnZ ys0Tk4pUv/XdiMZtVCGTNsotGeFbT5X64JkP/BFi3PVqjwy2VhOc -----END EC PRIVATE KEY-----'); - $this->assertSame('secp256k1', $key->getCurve()); + $this->assertSameNL('secp256k1', $key->getCurve()); // this key and the above key have a few small differences. // in both keys the coefficient's are 0 and 7. in the above @@ -75,7 +75,7 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAABwRBBHm+Zn753LusVaBilc6HCwcCm/zbLc4o E5w= -----END EC PRIVATE KEY-----'; PKCS1::useSpecifiedCurve(); - $this->assertSame($expected, $key->toString('PKCS1')); + $this->assertSameNL($expected, $key->toString('PKCS1')); } // openssl ecparam -name secp256k1 -genkey -noout -out secp256k1.pem @@ -87,8 +87,8 @@ MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgAYCXwnhqMT6fCIKIkQ0w cac7QqHrn4TCQMF9a+im74WhRANCAATwCjyGuP8xQbvVjznqazL36oeAnD32I+X2 +wscW3OmyTDpk41HaWYPh+j+BoufsSkCwf8dBRGEQbCieZbbZogy -----END PRIVATE KEY-----'); - $this->assertSame('secp256k1', $key->getCurve()); - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL('secp256k1', $key->getCurve()); + $this->assertSameNL($expected, $key->toString('PKCS8')); } // openssl ecparam -name secp256k1 -genkey -noout -out secp256k1.pem -param_enc explicit @@ -104,7 +104,7 @@ IKFfw3vfd5pqA5SZOTFtpr7hdJoKP/rmTPMCggkAOA35oUQDQgAEnX66+UCzUW3T /fkLGIIfZjJm5bIMwAV85LpDom2hI441JRx+/W4WqtGuW+B/LABS6ZHp+qzepThC HsjS3Q9Pew== -----END PRIVATE KEY-----'); - $this->assertSame('secp256k1', $key->getCurve()); + $this->assertSameNL('secp256k1', $key->getCurve()); // see testPKCS1PrivateKeySpecifiedCurve for an explanation // of how this key and the above key differ @@ -119,7 +119,7 @@ AASdfrr5QLNRbdP9+QsYgh9mMmblsgzABXzkukOibaEjjjUlHH79bhaq0a5b4H8s AFLpken6rN6lOEIeyNLdD097 -----END PRIVATE KEY-----'; PKCS8::useSpecifiedCurve(); - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL($expected, $key->toString('PKCS8')); } // openssl ecparam -name sect113r1 -genkey -noout -out sect113r1.pem @@ -129,10 +129,10 @@ AFLpken6rN6lOEIeyNLdD097 MEECAQEEDwBZdP4eSzKk/uQa6jdtfKAHBgUrgQQABKEiAyAABAHqCoNb++mK5qvE c4rCzQEuI19czqvXpEPcAWSXew== -----END EC PRIVATE KEY-----'); - $this->assertSame('sect113r1', $key->getCurve()); + $this->assertSameNL('sect113r1', $key->getCurve()); PKCS1::useNamedCurve(); - $this->assertSame($expected, $key->toString('PKCS1')); + $this->assertSameNL($expected, $key->toString('PKCS1')); } // openssl ecparam -name sect113r1 -genkey -noout -out sect113r1.pem -param_enc explicit @@ -145,7 +145,7 @@ AxUAEOcjqxTWluZ2h1YVF1b+v4/LSakEHwQAnXNhbzX0qxQH1zViwQ8ApSgwJ3lY 7oTRMV7TGIYCDwEAAAAAAAAA2czsijnlbwIBAqEiAyAABAFC7c50y7uw+iuHeMCt WwCpKNBUcVeiHme609Dv/g== -----END EC PRIVATE KEY-----'); - $this->assertSame('sect113r1', $key->getCurve()); + $this->assertSameNL('sect113r1', $key->getCurve()); // this key and the above key have a few small differences. // the above key has the (optional) seed for the verifiably @@ -159,7 +159,7 @@ BACdc2FvNfSrFAfXNWLBDwClKDAneVjuhNExXtMYhgIPAQAAAAAAAADZzOyKOeVv oSIDIAAEAULtznTLu7D6K4d4wK1bAKko0FRxV6IeZ7rT0O/+ -----END EC PRIVATE KEY-----'; PKCS1::useSpecifiedCurve(); - $this->assertSame($expected, $key->toString('PKCS1')); + $this->assertSameNL($expected, $key->toString('PKCS1')); } // openssl ecparam -name sect113r1 -genkey -noout -out sect113r1.pem @@ -171,10 +171,10 @@ oSIDIAAEAULtznTLu7D6K4d4wK1bAKko0FRxV6IeZ7rT0O/+ MFECAQAwEAYHKoZIzj0CAQYFK4EEAAQEOjA4AgEBBA8A5OuqAY8HYoFOaz9mE6mh IgMgAAQASF3rOTPXvH0QdRBvsrMBdLMf27yd8AWABrZTxvI= -----END PRIVATE KEY-----'); - $this->assertSame('sect113r1', $key->getCurve()); + $this->assertSameNL('sect113r1', $key->getCurve()); PKCS8::useNamedCurve(); - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL($expected, $key->toString('PKCS8')); } // openssl ecparam -name sect113r1 -genkey -noout -out sect113r1.pem -param_enc explicit @@ -188,7 +188,7 @@ AgMCAgEJMDcEDjCIJQym58f+ZJzoWCD3BA7ovuTT4iYHRBiL4OnHIwMVABDnI6sU Ag8BAAAAAAAAANnM7Io55W8CAQIEOjA4AgEBBA8AXtfDMRsRTx8snPbWHquhIgMg AAQA9xdWGJ6vV23+vkdq0C8BLJVg5E3amMyf/5keGa4= -----END PRIVATE KEY-----'); - $this->assertSame('sect113r1', $key->getCurve()); + $this->assertSameNL('sect113r1', $key->getCurve()); // see testBinaryPKCS1PrivateKeySpecifiedCurve() for an // explanation of the differences between the above key @@ -201,7 +201,7 @@ BA8AXtfDMRsRTx8snPbWHquhIgMgAAQA9xdWGJ6vV23+vkdq0C8BLJVg5E3amMyf /5keGa4= -----END PRIVATE KEY-----'; PKCS8::useSpecifiedCurve(); - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL($expected, $key->toString('PKCS8')); } // openssl ecparam -name sect131r1 -genkey -noout -out sect131r1.pem -param_enc explicit @@ -215,7 +215,7 @@ AhfAVhCIS2O5xscpFnj500EDFQBNaW5naHVhUXWYW9OtutohtDqX4gQjBACBuvkf 35gzxA+cGBNDY4OZB4xufqOMAB9zyBNLG0754VACEQQAAAAAAAAAAjEjlTqUZLVN AgECoSYDJAAEBEIolGjo5lnsYqNagqYPOaEGOglkllDO2aWPtB6n+x/WXw== -----END EC PRIVATE KEY-----'); - $this->assertSame('sect131r1', $key->getCurve()); + $this->assertSameNL('sect131r1', $key->getCurve()); // see testBinaryPKCS1PrivateKeySpecifiedCurve() for an // explanation of the differences between the above key @@ -228,7 +228,7 @@ SxtO+eFQAhEEAAAAAAAAAAIxI5U6lGS1TaEmAyQABARCKJRo6OZZ7GKjWoKmDzmh BjoJZJZQztmlj7Qep/sf1l8= -----END EC PRIVATE KEY-----'; PKCS1::useSpecifiedCurve(); - $this->assertSame($expected, $key->toString('PKCS1')); + $this->assertSameNL($expected, $key->toString('PKCS1')); } // from https://tools.ietf.org/html/draft-ietf-curdle-pkix-07#section-10.1 @@ -237,7 +237,7 @@ BjoJZJZQztmlj7Qep/sf1l8= $key = PublicKeyLoader::load('-----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE= -----END PUBLIC KEY-----'); - $this->assertSame('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); // in the above key AlgorithmIdentifier has a single "child". in the // following key it has two. The second one is ("optional") NULL. @@ -246,7 +246,7 @@ MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE= $expected = '-----BEGIN PUBLIC KEY----- MCwwBwYDK2VwBQADIQAZv0QJaYTN/oVBusFn3DuWyFCGqjC2tssMXDitcDFm4Q== -----END PUBLIC KEY-----'; - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL($expected, $key->toString('PKCS8')); } // from https://tools.ietf.org/html/draft-ietf-curdle-pkix-07#section-10.3 @@ -256,8 +256,8 @@ MCwwBwYDK2VwBQADIQAZv0QJaYTN/oVBusFn3DuWyFCGqjC2tssMXDitcDFm4Q== $key = PublicKeyLoader::load('-----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC -----END PRIVATE KEY-----'); - $this->assertSame('Ed25519', $key->getCurve()); - $this->assertSame('Ed25519', $key->getPublicKey()->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getPublicKey()->getCurve()); // with public key $key = PublicKeyLoader::load('-----BEGIN PRIVATE KEY----- @@ -265,8 +265,8 @@ MHICAQEwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC oB8wHQYKKoZIhvcNAQkJFDEPDA1DdXJkbGUgQ2hhaXJzgSEAGb9ECWmEzf6FQbrB Z9w7lshQhqowtrbLDFw4rXAxZuE= -----END PRIVATE KEY-----'); - $this->assertSame('Ed25519', $key->getCurve()); - $this->assertSame('Ed25519', $key->getPublicKey()->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getPublicKey()->getCurve()); // the above key not only omits NULL - it also includes a // unstructuredName attribute with a value of "Curdle Chairs" @@ -275,12 +275,12 @@ Z9w7lshQhqowtrbLDFw4rXAxZuE= MFMCAQEwBwYDK2VwBQAEIgQg1O5y2/kTWErVttjx92n4rTr+fCjL8dT74Jeoj0R1 WEKBIQAZv0QJaYTN/oVBusFn3DuWyFCGqjC2tssMXDitcDFm4Q== -----END PRIVATE KEY-----'; - $this->assertSame($expected, $key->toString('PKCS8')); + $this->assertSameNL($expected, $key->toString('PKCS8')); $expected = EC::createKey('Ed25519')->toString('PKCS8'); $key = PublicKeyLoader::load($expected); - $this->assertSame('Ed25519', $key->getCurve()); - $this->assertSame('Ed25519', $key->getPublicKey()->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getPublicKey()->getCurve()); } public function testPuTTYnistp256() @@ -296,16 +296,16 @@ Private-Lines: 1 AAAAIQDwaPlajbXY1SxhuwsUqN1CEZ5g4adsbmJsKm+ZbUVm4g== Private-MAC: b85ca0eb7c612df5d18af85128821bd53faaa3ef '); - $this->assertSame('secp256r1', $key->getCurve()); + $this->assertSameNL('secp256r1', $key->getCurve()); PuTTY::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('PuTTY')); + $this->assertSameNL($expected, $key->toString('PuTTY')); $key = PublicKeyLoader::load($expected = 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJEXCsWA8s18m25MJlVE1urbXPYFi4q8oMbb2H0kE2f5WPxizsKXRmb1J68paXQizryL9fC4FTqICJ1+UnaPfk0= ecdsa-key-20181105'); - $this->assertSame('secp256r1', $key->getCurve()); + $this->assertSameNL('secp256r1', $key->getCurve()); OpenSSH::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('OpenSSH')); + $this->assertSameNL($expected, $key->toString('OpenSSH')); } public function testPuTTYnistp384() @@ -322,16 +322,16 @@ AAAAMQCEMkGMDg6N7bUqdvLXe0YmY4qBSi8hmAuMvU38RDoVFVmV+R4RYmMueyrX be9Oyus= Private-MAC: 97a990a3d5f6b8f268d4be9c4ab9ebfd8fa79849 '); - $this->assertSame('secp384r1', $key->getCurve()); + $this->assertSameNL('secp384r1', $key->getCurve()); PuTTY::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('PuTTY')); + $this->assertSameNL($expected, $key->toString('PuTTY')); $key = PublicKeyLoader::load($expected = 'ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBOI53wHG3CdcAJZq5PXWZAEAxxsNVFQlQgOX9toWEOgqQF5LbK2nWLKRvaHMzocUXaTYZDccSS0ATZFPT3j1Er1LU9cu4PHpyS07v262jdzkxIvKCPcAeISuV80MC7rHog== ecdsa-key-20181105'); - $this->assertSame('secp384r1', $key->getCurve()); + $this->assertSameNL('secp384r1', $key->getCurve()); OpenSSH::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('OpenSSH')); + $this->assertSameNL($expected, $key->toString('OpenSSH')); } @@ -350,16 +350,16 @@ AAAAQgHJl8/dIArolFymdzhagXCfd2l8UF3CQXWGVGDQ0R04nnntlyztYiVdRXXK r84NnzS7dJcAsR9YaUOZ69NRKNiUAQ== Private-MAC: 6d49ce289b85549a43d74422dd8bb3ba8798c72c '); - $this->assertSame('secp521r1', $key->getCurve()); + $this->assertSameNL('secp521r1', $key->getCurve()); PuTTY::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('PuTTY')); + $this->assertSameNL($expected, $key->toString('PuTTY')); $key = PublicKeyLoader::load($expected = 'ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAF1Eg0MjaJwooFj6HCNh4RWbvmQRY+sdczJyBdT3EaTc/6IUcCfW7w7rAeRp2CDdE9RlAVD8IuLqW7DJH06Xeov8wBO5G6jUqXu0rlHsOSiC6VcCxBJuWVNB1IorHnS7PX0f6HdLlIEme73P77drqpn5YY0XLtP6hFrF7H5XfCxpNyaJA== ecdsa-key-20181105'); - $this->assertSame('secp521r1', $key->getCurve()); + $this->assertSameNL('secp521r1', $key->getCurve()); OpenSSH::setComment('ecdsa-key-20181105'); - $this->assertSame($expected, $key->toString('OpenSSH')); + $this->assertSameNL($expected, $key->toString('OpenSSH')); } public function testPuTTYed25519() @@ -374,16 +374,16 @@ Private-Lines: 1 AAAAIAHu1uI7dxFzo/SleEI2CekXKmgqlXwOgvfaRWxiX4Jd Private-MAC: 8a06821a1c8b8b40fc40f876e543c4ea3fb81bb9 '); - $this->assertSame('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); PuTTY::setComment('ed25519-key-20181105'); - $this->assertSame($expected, $key->toString('PuTTY')); + $this->assertSameNL($expected, $key->toString('PuTTY')); $key = PublicKeyLoader::load($expected = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC6I6RyYAqtBcWXws9EDqGbhFtc5rKG4NMn/G7temQtu ed25519-key-20181105'); - $this->assertSame('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); OpenSSH::setComment('ed25519-key-20181105'); - $this->assertSame($expected, $key->toString('OpenSSH')); + $this->assertSameNL($expected, $key->toString('OpenSSH')); } public function testlibsodium() @@ -395,12 +395,12 @@ Private-MAC: 8a06821a1c8b8b40fc40f876e543c4ea3fb81bb9 $kp = sodium_crypto_sign_keypair(); $key = EC::loadFormat('libsodium', $expected = sodium_crypto_sign_secretkey($kp)); - $this->assertSame('Ed25519', $key->getCurve()); - $this->assertSame($expected, $key->toString('libsodium')); + $this->assertSameNL('Ed25519', $key->getCurve()); + $this->assertSameNL($expected, $key->toString('libsodium')); $key = EC::loadFormat('libsodium', $expected = sodium_crypto_sign_publickey($kp)); - $this->assertSame('Ed25519', $key->getCurve()); - $this->assertSame($expected, $key->toString('libsodium')); + $this->assertSameNL('Ed25519', $key->getCurve()); + $this->assertSameNL($expected, $key->toString('libsodium')); } // ssh-keygen -t ed25519 @@ -413,7 +413,7 @@ eQAAAAtzc2gtZWQyNTUxOQAAACCpm7dS1/WDTW+uuhp2+aFLPKaJle6+oJqDGLXhlQAX4A AAAEDltCTSbrr42IS4hhkS6ly0W2XItRQwxjLT+03bIyA+V6mbt1LX9YNNb666Gnb5oUs8 pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== -----END OPENSSH PRIVATE KEY-----'); - $this->assertSame('Ed25519', $key->getCurve()); + $this->assertSameNL('Ed25519', $key->getCurve()); // testing this key is a little difficult because of this format's // two back to back checkint fields. both fields correspond to the @@ -423,7 +423,7 @@ pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== // none-the-less, because of the randomized component we can't easily // see if the key string is equal to another known string $key2 = PublicKeyLoader::load($key->toString('OpenSSH')); - $this->assertSame('Ed25519', $key2->getCurve()); + $this->assertSameNL('Ed25519', $key2->getCurve()); } // from https://www.w3.org/TR/xmldsig-core/#sec-RFC4050Compat @@ -438,7 +438,7 @@ pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== '); - $this->assertSame('secp256r1', $key->getCurve()); + $this->assertSameNL('secp256r1', $key->getCurve()); XML::enableRFC4050Syntax(); @@ -452,14 +452,14 @@ pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== $dom->loadXML($key->toString('XML')); $actual = $dom->C14N(); - $this->assertSame($expected, $actual); + $this->assertSameNL($expected, $actual); } - public static function assertSame($expected, $actual, $message = '') + public function assertSameNL($expected, $actual, $message = '') { $expected = str_replace("\r\n", "\n", $expected); $actual = str_replace("\r\n", "\n", $actual); - return parent::assertSame($expected, $actual, $message); + $this->assertSame($expected, $actual, $message); } public function testOpenSSHPrivateEC() diff --git a/tests/Unit/Crypt/HashTest.php b/tests/Unit/Crypt/HashTest.php index 204169b5..80e57f40 100644 --- a/tests/Unit/Crypt/HashTest.php +++ b/tests/Unit/Crypt/HashTest.php @@ -6,6 +6,7 @@ */ use phpseclib3\Crypt\Hash; +use phpseclib3\Exception\UnsupportedAlgorithmException; class Unit_Crypt_HashTest extends PhpseclibTestCase { @@ -373,19 +374,17 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase $this->assertSame($hash->getHash(), 'sha256'); } - /** - * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException - */ public function testConstructorArgumentInvalid() { + $this->expectException(UnsupportedAlgorithmException::class); + new Hash('abcdefghijklmnopqrst'); } - /** - * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException - */ public function testSetHashInvalid() { + $this->expectException(UnsupportedAlgorithmException::class); + $hash = new Hash('md5'); $hash->setHash('abcdefghijklmnopqrst-96'); } @@ -465,22 +464,3 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase $this->assertSame($hash->hash($message), pack('H*', $tag), $error); } } - -class HashTest extends Unit_Crypt_HashTest -{ - /** - * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException - */ - public function testConstructorArgumentInvalid() - { - parent::testConstructorArgumentInvalid(); - } - - /** - * @expectedException \phpseclib3\Exception\UnsupportedAlgorithmException - */ - public function testSetHashInvalid() - { - parent::testSetHashInvalid(); - } -} diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index c778d777..9105e484 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -15,6 +15,8 @@ use phpseclib3\Crypt\RSA\Formats\Keys\PuTTY; use phpseclib3\Crypt\RSA\Formats\Keys\OpenSSH; use phpseclib3\Crypt\RSA\Formats\Keys\PSS; use phpseclib3\Math\BigInteger; +use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Exception\NoKeyLoadedException; class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase { @@ -24,11 +26,10 @@ class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase OpenSSH::setComment('phpseclib-generated-key'); } - /** - * @expectedException \phpseclib3\Exception\NoKeyLoadedException - */ public function testBadKey() { + $this->expectException(NoKeyLoadedException::class); + $key = 'zzzzzzzzzzzzzz'; PublicKeyLoader::load($key); } @@ -1016,11 +1017,10 @@ YYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ $this->assertInstanceOf(PublicKey::class, $key); } - /** - * @expectedException \phpseclib3\Exception\UnsupportedFormatException - */ public function testSavePasswordXML() { + $this->expectException(UnsupportedFormatException::class); + $key = '-----BEGIN RSA PRIVATE KEY----- MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu KUpRKfFLfRYC9AIKjbJTWit+CqvjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index bc4e12e4..c1202a51 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -67,11 +67,10 @@ p0GbMJDyR4e9T04ZZwIDAQAB $this->assertTrue($rsa->verify('zzzz', $sig)); } - /** - * @expectedException \LengthException - */ public function testSmallModulo() { + $this->expectException('LengthException'); + $plaintext = 'x'; $key = PKCS8::savePublicKey( diff --git a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php index c4a28bcf..a49eecab 100644 --- a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php @@ -7,11 +7,13 @@ use \phpseclib3\Math\BigInteger\Engines\PHP64; -class Unit_Math_BigInteger_PHP64OpenSSLTest extends Unit_Math_BigInteger_PHP64Test +class Unit_Math_BigInteger_PHP64OpenSSLTest extends Unit_Math_BigInteger_TestCase { public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + if (!PHP64::isValidEngine()) { + self::markTestSkipped('64-bit integers are not available.'); + } try { PHP64::setModExpEngine('OpenSSL'); @@ -19,4 +21,22 @@ class Unit_Math_BigInteger_PHP64OpenSSLTest extends Unit_Math_BigInteger_PHP64Te self::markTestSkipped('openssl_public_encrypt() function is not available.'); } } + + public function getInstance($x = 0, $base = 10) + { + return new PHP64($x, $base); + } + + public function testInternalRepresentation() + { + $x = new PHP64('FFFFFFFFFFFFFFFFC90FDA', 16); + $y = new PHP64("$x"); + + $this->assertSame(self::getVar($x, 'value'), self::getVar($y, 'value')); + } + + public static function getStaticClass() + { + return 'phpseclib3\Math\BigInteger\Engines\PHP64'; + } } diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 96f420e7..95a419b1 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -25,19 +25,17 @@ then find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUpBeforeClass()/n setUpBeforeClass(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUp()/n setUp(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n tearDown()/n tearDown(): void/g' - find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n assertSame()/n assertSame(): void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsArray([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsResource([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsObject([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringContainsString([^)]*)\)/\1: void/g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringNotContainsString([^)]*)\)/\1: void/g' - find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Crypt_\(AES\|Hash\|RSA\)_/class /g' + find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Crypt_\(AES\|DSA\|EC\|RSA\)_/class /g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_File_\(X509\)_/class /g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Math_\(BigInteger\)_/class /g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_\(Crypt\|File\|Math\|Net\)_/class /g' find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Functional_Net_/class /g' - find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/extends Unit_Crypt_Hash_\(SHA512Test\|SHA256Test\)/extends \1/g' fi if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '>=');"` = "1" ]