Merge branch '2.0' into 3.0

This commit is contained in:
terrafrost 2020-12-12 19:22:36 -06:00
commit e4bf7b111a
49 changed files with 349 additions and 110 deletions

View File

@ -9,6 +9,7 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0
- nightly
before_install: true
@ -20,7 +21,7 @@ matrix:
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

View File

@ -11,6 +11,7 @@
using underscore. -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
</rule>
</ruleset>

View File

@ -57,7 +57,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": {

View File

@ -315,19 +315,20 @@ class 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;
@ -340,23 +341,23 @@ class 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:

View File

@ -16,6 +16,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();
}
@ -41,3 +42,7 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase
);
}
}
class SFTPLargeFileTest extends Functional_Net_SFTPLargeFileTest
{
}

View File

@ -22,7 +22,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
'sftp' => ['session' => $this->sftp],
]);
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
$this->assertInternalType('resource', $fp);
$this->assertIsResource($fp);
fclose($fp);
$this->assertSame(0, $this->sftp->filesize('fooo.txt'));
}
@ -64,3 +64,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
);
}
}
class SFTPStreamTest extends Functional_Net_SFTPStreamTest
{
}

View File

@ -29,8 +29,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
{
$sftp = new SFTP($this->getEnv('SSH_HOSTNAME'));
$this->assertInternalType(
'object',
$this->assertIsObject(
$sftp,
'Could not construct NET_SFTP object.'
);
@ -136,6 +135,16 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
return $sftp;
}
static function demoCallback($length)
{
$r = substr(self::$buffer, 0, $length);
self::$buffer = substr(self::$buffer, $length);
if (strlen($r)) {
return $r;
}
return null;
}
/**
* @depends testStatOnDir
*/
@ -161,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
*/
@ -178,7 +177,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
{
self::$buffer = self::$exampleData;
$this->assertTrue(
$sftp->put('file1.txt', [__CLASS__, 'callback'], $sftp::SOURCE_CALLBACK),
$sftp->put('file1.txt', [__CLASS__, 'demoCallback'], $sftp::SOURCE_CALLBACK),
'Failed asserting that example data could be successfully put().'
);
@ -440,8 +439,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'
);
@ -456,14 +454,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'
);
@ -605,8 +601,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 existent empty directory returns an array'
);
@ -753,3 +748,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
{
}

View File

@ -53,3 +53,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase
return $args;
}
}
class SSH2AgentTest extends Functional_Net_SSH2AgentTest
{
}

View File

@ -14,8 +14,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
{
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
$this->assertInternalType(
'object',
$this->assertIsObject
$ssh,
'Could not construct NET_SSH2 object.'
);
@ -125,7 +124,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
{
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
$this->assertInternalType('string', $ssh->getServerPublicHostKey());
$this->assertIsString($ssh->getServerPublicHostKey());
}
public function testOpenSocketConnect()
@ -173,3 +172,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
$ssh->read();
}
}
class SSH2Test extends Functional_Net_SSH2Test
{
}

View File

@ -117,4 +117,70 @@ abstract class PhpseclibTestCase extends PHPUnit\Framework\TestCase
$method->setAccessible(true);
return $method->invokeArgs($obj, $params);
}
// 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);
}
// assertIsResource was not introduced until PHPUnit 8
public static function assertIsResource($actual, $message = '')
{
if (method_exists('\PHPUnit\Framework\TestCase', 'assertIsResource')) {
parent::assertIsResource($actual, $message);
return;
}
parent::assertInternalType('resource', $actual, $message);
}
// assertIsObject was not introduced until PHPUnit 8
public static function assertIsObject($actual, $message = '')
{
if (method_exists('\PHPUnit\Framework\TestCase', 'assertIsObject')) {
parent::assertIsObject($actual, $message);
return;
}
parent::assertInternalType('object', $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);
}
}

View File

@ -14,3 +14,7 @@ class Unit_Crypt_AES_EvalTest extends Unit_Crypt_AES_TestCase
$this->engine = 'Eval';
}
}
class EvalTest extends Unit_Crypt_AES_EvalTest
{
}

View File

@ -14,3 +14,7 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase
$this->engine = 'mcrypt';
}
}
class McryptTest extends Unit_Crypt_AES_McryptTest
{
}

View File

@ -14,3 +14,7 @@ class Unit_Crypt_AES_OpenSSLTest extends Unit_Crypt_AES_TestCase
$this->engine = 'OpenSSL';
}
}
class OpenSSLTest extends Unit_Crypt_AES_OpenSSLTest
{
}

View File

@ -7,10 +7,14 @@
use phpseclib3\Crypt\Common\BlockCipher;
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 = 'PHP';
}
}
class PurePHPTest extends Unit_Crypt_AES_PurePHPTest
{
}

View File

@ -131,3 +131,7 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase
}
}
}
class BlowfishTest extends Unit_Crypt_BlowfishTest
{
}

View File

@ -216,3 +216,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
}
}
}
class ChaCha20Test extends Unit_Crypt_ChaCha20Test
{
}

View File

@ -30,7 +30,7 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL
public function testParametersWithInteger()
{
$a = DH::createParameters(512);
$this->assertInternalType('string', "$a");
$this->assertIsString("$a");
}
public function testParametersWithBigIntegers()
@ -55,8 +55,8 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL
{
$param = DH::createParameters('diffie-hellman-group1-sha1');
$key = DH::createKey($param);
$this->assertInternalType('string', "$key");
$this->assertInternalType('string', (string) $key->getPublicKey());
$this->assertIsString("$key");
$this->assertIsString((string) $key->getPublicKey());
}
public function testLoadPrivate()
@ -119,7 +119,7 @@ i2REGZNPWmF3SRPrtq/4urrDRU0F2eQks7qnTkrauPK1/UvE1gwbqWrWgBko+6L+
Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU
/gTm
-----END PUBLIC KEY-----');
$this->assertInternalType('string', DH::computeSecret($ourPriv, $theirPub));
$this->assertIsString(DH::computeSecret($ourPriv, $theirPub));
}
public function testComputeSecret()
@ -130,7 +130,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU
foreach ($curves as $curve) {
$ourPriv = EC::createKey($curve);
$theirPub = EC::createKey($curve)->getPublicKey();
$this->assertInternalType('string', DH::computeSecret($ourPriv, $theirPub));
$this->assertIsString(DH::computeSecret($ourPriv, $theirPub));
}
}
@ -264,3 +264,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU
$this->assertSame($expected, DH::computeSecret($bobPrivate, $alicePublic));
}
}
class DHTest extends Unit_Crypt_DHTest
{
}

View File

@ -54,3 +54,6 @@ class Unit_Crypt_DSA_CreateKeyTest extends PhpseclibTestCase
}
}
class CreateKeyTest extends Unit_Crypt_DSA_CreateKeyTest
{
}

View File

@ -14,7 +14,7 @@ use phpseclib3\Crypt\DSA\Formats\Keys\PKCS8;
use phpseclib3\Crypt\DSA\Formats\Keys\PuTTY;
use phpseclib3\Math\BigInteger;
class Unit_Crypt_DSA_LoadKeyTest extends PhpseclibTestCase
class Unit_Crypt_DSA_LoadDSAKeyTest extends PhpseclibTestCase
{
/**
* @expectedException \phpseclib3\Exception\NoKeyLoadedException
@ -57,9 +57,9 @@ Private-MAC: 62b92ddd8b341b9414d640c24ba6ae929a78e039
$dsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $dsa);
$this->assertInternalType('string', "$dsa");
$this->assertInternalType('string', $dsa->getPublicKey()->toString('PuTTY'));
$this->assertInternalType('string', $dsa->getParameters()->toString('PuTTY'));
$this->assertIsString("$dsa");
$this->assertIsString($dsa->getPublicKey()->toString('PuTTY'));
$this->assertIsString($dsa->getParameters()->toString('PuTTY'));
$dsa = $dsa->withPassword('password');
$this->assertGreaterThan(0, strlen("$dsa"));
@ -91,9 +91,9 @@ Eb2s9fDOpnMhj+WqwcQgs18=
$dsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $dsa);
$this->assertInternalType('string', "$dsa");
$this->assertInternalType('string', $dsa->getPublicKey()->toString('PKCS1'));
$this->assertInternalType('string', (string) $dsa->getParameters());
$this->assertIsString("$dsa");
$this->assertIsString($dsa->getPublicKey()->toString('PKCS1'));
$this->assertIsString((string) $dsa->getParameters());
}
public function testParameters()
@ -133,7 +133,7 @@ ZpmyOpXM/0opRMIRdmqVW4ardBFNokmlqngwcbaptfRnk9W2cQtx0lmKy6X/vnis
$dsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PublicKey::class, $dsa);
$this->assertInternalType('string', "$dsa");
$this->assertIsString("$dsa");
}
public function testPKCS8Private()
@ -151,7 +151,7 @@ Syea3pSvWdBpVhWzOX4A7qbxs+bhWAQWAhQiF7sFfCtZ7oOgCb2aJ9ySC9sTug==
$dsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $dsa);
$this->assertInternalType('string', "$dsa");
$this->assertIsString("$dsa");
$this->assertInstanceOf(PublicKey::class, $dsa->getPublicKey());
$this->assertInstanceOf(Parameters::class, $dsa->getParameters());
}
@ -208,7 +208,7 @@ ZpmyOpXM/0opRMIRdmqVW4ardBFNokmlqngwcbaptfRnk9W2cQtx0lmKy6X/vnis
$dsa = PublicKeyLoader::load($key);
$xml = $dsa->toString('XML');
$this->assertContains('DSAKeyValue', $xml);
$this->assertStringContainsString('DSAKeyValue', $xml);
$dsa = PublicKeyLoader::load($xml);
$pkcs8 = $dsa->toString('PKCS8');
@ -256,3 +256,7 @@ dlN48qLbSmUgsO7gq/1vodebMSHcduV4JTq8ix5Ey87QAAABQhHEzWiduF4V0DestSnJ3q
$this->assertTrue($key->verify('zzz', $sig));
}
}
class LoadDSAKeyTest extends Unit_Crypt_DSA_LoadDSAKeyTest
{
}

View File

@ -122,3 +122,7 @@ kBniZHdFBAZBTE14YJUBkw==
$this->assertTrue($dsa->verify($message, $signature));
}
}
class SignatureTest extends Unit_Crypt_DSA_SignatureTest
{
}

View File

@ -509,3 +509,7 @@ Private-MAC: b85ca0eb7c612df5d18af85128821bd53faaa3ef');
$this->assertTrue($public->verify($message, $signature, 'Raw'));
}
}
class CurveTest extends Unit_Crypt_EC_CurveTest
{
}

View File

@ -14,7 +14,7 @@ use phpseclib3\Crypt\EC\Formats\Keys\XML;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\EC\PrivateKey;
class Unit_Crypt_EC_LoadKeyTest extends PhpseclibTestCase
class Unit_Crypt_EC_KeyTest extends PhpseclibTestCase
{
public function testBinaryPKCS1PrivateParameters()
{
@ -508,3 +508,7 @@ lEIq93iMVzIArjGaKrFDAAAADHJvb3RAdmFncmFudAE=
$this->assertTrue($key->withSignatureFormat('SSH2')->verify('zzz', $sig2));
}
}
class KeyTest extends Unit_Crypt_EC_KeyTest
{
}

View File

@ -235,3 +235,7 @@ class Unit_Crypt_GCMTest extends PhpseclibTestCase
$this->assertEquals($plaintext, $aes->decrypt($ciphertext));
}
}
class GCMTest extends Unit_Crypt_GCMTest
{
}

View File

@ -465,3 +465,7 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase
$this->assertSame($hash->hash($message), pack('H*', $tag), $error);
}
}
class HashTest extends Unit_Crypt_HashTest
{
}

View File

@ -127,3 +127,7 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase
$this->assertEquals($result, $plaintext, "Failed asserting that decrypted result yielded $plaintext as a result in $engine engine");
}
}
class RC2Test extends Unit_Crypt_RC2Test
{
}

View File

@ -250,3 +250,7 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase
}
}
}
class RC4Test extends Unit_Crypt_RC4Test
{
}

View File

@ -34,7 +34,7 @@ class Unit_Crypt_RSA_CreateKeyTest extends PhpseclibTestCase
{
list($publickey, $privatekey) = $args;
$ciphertext = $publickey->encrypt('zzz');
$this->assertInternalType('string', $ciphertext);
$this->assertIsString($ciphertext);
$plaintext = $privatekey->decrypt($ciphertext);
$this->assertSame($plaintext, 'zzz');
}

View File

@ -52,7 +52,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$rsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testPKCS1SpacesKey()
@ -75,7 +75,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$rsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testPKCS1NoHeaderKey()
@ -95,7 +95,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$rsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testPKCS1NoWhitespaceNoHeaderKey()
@ -115,7 +115,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$rsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testRawPKCS1Key()
@ -136,7 +136,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$rsa = PublicKeyLoader::load($key);
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testLoadPKCS8PrivateKey()
@ -174,7 +174,7 @@ xryZaRDVmtMuf/OZBQ==
$rsa = PublicKeyLoader::load($key, 'password');
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', "$rsa");
$this->assertIsString("$rsa");
}
public function testSavePKCS8PrivateKey()
@ -247,7 +247,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
$rsa = PublicKeyLoader::load($key)->asPrivateKey();
$this->assertInstanceOf(PrivateKey::class, $rsa);
$this->assertInternalType('string', $rsa->sign('zzz'));
$this->assertIsString($rsa->sign('zzz'));
}
public function testSSHPubKey()
@ -574,6 +574,7 @@ mKVKf5kPx2aR2W2KAcgw3TJIu1QX7N+l3kFrf9Owtz1a
-----END ENCRYPTED PRIVATE KEY-----';
$pass = 'asdf';
<<<<<<< HEAD
$this->pkcs8tester($key, $pass);
}
@ -1043,6 +1044,10 @@ n9dyFZYXxil/cgFG/PDMnuXy1Wcl8hb8iwQag4Y7ohiLXVTJa/0BAgMBAAE=
-----END RSA PRIVATE KEY-----';
$key = PublicKeyLoader::load($key);
$result = $key->toString('PKCS1');
$this->assertInternalType('string', $result);
$this->assertIsString($result);
}
}
class LoadKeyTest extends Unit_Crypt_RSA_LoadKeyTest
{
}

View File

@ -184,3 +184,7 @@ HERE;
$this->assertEquals('sha1', $rsa->getMGFHash());
}
}
class ModeTest extends Unit_Crypt_RSA_ModeTest
{
}

View File

@ -53,3 +53,7 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase
return [$x];
}
}
class RandomTest extends Unit_Crypt_RandomTest
{
}

View File

@ -158,3 +158,7 @@ class Unit_Crypt_Salsa20Test extends PhpseclibTestCase
$this->assertEquals(bin2hex($result), $expected, "Failed asserting that key $key / $iv yielded expected output in $engine engine");
}
}
class Salsa20Test extends Unit_Crypt_Salsa20Test
{
}

View File

@ -201,3 +201,7 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
}
}
}
class TripleDESTest extends Unit_Crypt_TripleDESTest
{
}

View File

@ -73,3 +73,7 @@ class Unit_Crypt_TwofishTest extends PhpseclibTestCase
}
}
}
class TwofishTest extends Unit_Crypt_TwofishTest
{
}

View File

@ -63,3 +63,7 @@ class Unit_File_ANSITest extends PhpseclibTestCase
$this->assertSame(str_repeat('z', 80), $lines[22]);
}
}
class ANSITest extends Unit_File_ANSITest
{
}

View File

@ -78,7 +78,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);
}
/**
@ -229,7 +229,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);
}
/**
@ -271,7 +271,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
public function testContextSpecificNonConstructed()
{
$decoded = ASN1::decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv'));
$this->assertInternalType('string', $decoded[0]['content'][0]['content']);
$this->assertIsString($decoded[0]['content'][0]['content']);
}
/**
@ -280,7 +280,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
public function testEmptyContextTag()
{
$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
{
}

View File

@ -28,7 +28,7 @@ v5RwaQHmQEzHofTzF7I+
$spkac = $x509->loadCSR($test);
$this->assertInternalType('array', $spkac);
$this->assertIsArray($spkac);
}
public function testCSRWithAttributes()
@ -68,7 +68,7 @@ draiRBZruwMPwPIP
$csr = $x509->loadCSR($test);
$this->assertInternalType('array', $csr);
$this->assertIsArray($csr);
}
public function testCSRDER()
@ -93,7 +93,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
@ -121,3 +121,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$x509->saveCSR($x509->signCSR(), X509::FORMAT_DER);
}
}
class CSRTest extends Unit_File_X509_CSRTest
{
}

View File

@ -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 X509();
$x509->setPrivateKey($privatekey);
$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
{
}

View File

@ -59,7 +59,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()
@ -865,7 +865,7 @@ uhPlgkgknwIgdDqqKIAF60ouiynsbU53ERS0TwpjeFiYGA48SwYW3Nk=
$result = $x509->sign($issuer, $subject);
$result = $x509->saveX509($result);
$this->assertInternalType('string', $result);
$this->assertIsString($result);
$r = $x509->loadX509($result);
$this->assertSame('id-dsa-with-sha256', $r['tbsCertificate']['signature']['algorithm']);
@ -896,7 +896,7 @@ wkwhE/JaQAEHq2PHnEmvwyBiJcHSdLXkcLzYlg19Ho0BPqVKdulx8GAk
$result = $x509->sign($issuer, $subject);
$result = $x509->saveX509($result);
$this->assertInternalType('string', $result);
$this->assertIsString($result);
$r = $x509->loadX509($result);
$this->assertSame('ecdsa-with-SHA256', $r['tbsCertificate']['signature']['algorithm']);
@ -935,7 +935,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$result = $x509->sign($issuer, $subject);
$result = $x509->saveX509($result);
$this->assertInternalType('string', $result);
$this->assertIsString($result);
$r = $x509->loadX509($result);
$this->assertSame('id-RSASSA-PSS', $r['tbsCertificate']['signature']['algorithm']);
@ -979,7 +979,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
$result = $x509->sign($issuer, $subject);
$result = $x509->saveX509($result);
$this->assertInternalType('string', $result);
$this->assertIsString($result);
$r = $x509->loadX509($result);
$this->assertSame('sha256WithRSAEncryption', $r['tbsCertificate']['signature']['algorithm']);
@ -1170,3 +1170,7 @@ mDaPrsUl15evEah6amsBfpQiWRbKpDLKs1kF
$this->assertFalse($r);
}
}
class X509Test extends Unit_File_X509_X509Test
{
}

View File

@ -27,3 +27,7 @@ class Unit_Math_BigInteger_BCMathTest extends Unit_Math_BigInteger_TestCase
return 'phpseclib3\Math\BigInteger\Engines\BCMath';
}
}
class BCMathTest extends Unit_Math_BigInteger_BCMathTest
{
}

View File

@ -19,3 +19,7 @@ class Unit_Math_BigInteger_DefaultTest extends Unit_Math_BigInteger_TestCase
return 'phpseclib3\Math\BigInteger';
}
}
class DefaultTest extends Unit_Math_BigInteger_DefaultTest
{
}

View File

@ -27,3 +27,7 @@ class Unit_Math_BigInteger_GMPTest extends Unit_Math_BigInteger_TestCase
return 'phpseclib3\Math\BigInteger\Engines\GMP';
}
}
class GMPTest extends Unit_Math_BigInteger_GMPTest
{
}

View File

@ -36,3 +36,7 @@ class Unit_Math_BigInteger_PHP32Test extends Unit_Math_BigInteger_TestCase
return 'phpseclib3\Math\BigInteger\Engines\PHP32';
}
}
class PHP32Test extends Unit_Math_BigInteger_PHP32Test
{
}

View File

@ -20,3 +20,7 @@ class Unit_Math_BigInteger_PHP64OpenSSLTest extends Unit_Math_BigInteger_PHP64Te
}
}
}
class PHP64OpenSSLTest extends Unit_Math_BigInteger_PHP64OpenSSLTest
{
}

View File

@ -35,3 +35,7 @@ class Unit_Math_BigInteger_PHP64Test extends Unit_Math_BigInteger_TestCase
return 'phpseclib3\Math\BigInteger\Engines\PHP64';
}
}
classs PHP64Test extends Unit_Math_BigInteger_PHP64Test
{
}

View File

@ -384,7 +384,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);
}
public function testPrecision()

View File

@ -71,3 +71,7 @@ ENGINE
static::assertSame($expectedEngineClass, $bigint->toString());
}
}
class BigIntegerTest extends Unit_Math_BigIntegerTest
{
}

View File

@ -7,7 +7,7 @@
use phpseclib3\Net\SFTP\Stream;
class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
class Unit_Net_SFTPStreamUnitTest extends PhpseclibTestCase
{
public function testRegisterWithoutArgument()
{
@ -24,3 +24,7 @@ class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
$this->assertTrue(stream_wrapper_unregister($protocol));
}
}
class SFTPStreamUnitTest extends Unit_Net_SFTPStreamUnitTest
{
}

View File

@ -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()
{
@ -41,30 +41,30 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
$identifier = self::callFunc($this->createSSHMock(), 'generate_identifier');
$this->assertStringStartsWith('SSH-2.0-phpseclib_3.0', $identifier);
if (function_exists('\\Sodium\\library_version_major')) {
if (function_exists('sodium_crypto_sign_keypair')) {
$this->assertContains('libsodium', $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);
}
}
@ -133,3 +133,7 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
->getMock();
}
}
class SSH2UnitTest extends Unit_Net_SSH2UnitTest
{
}

View File

@ -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" | \