mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-30 04:39:02 +01:00
Merge remote-tracking branch 'origin/authenticated-2.0' into 2.0
This commit is contained in:
commit
d86550f5de
@ -19,7 +19,13 @@ env:
|
||||
before_install: true
|
||||
|
||||
install:
|
||||
- sudo apt-get install parallel
|
||||
- wget http://ftp.gnu.org/gnu/parallel/parallel-20120522.tar.bz2
|
||||
- tar -xvjf parallel*
|
||||
- cd parallel*
|
||||
- ./configure
|
||||
- make
|
||||
- sudo make install
|
||||
- cd ..
|
||||
- eval `ssh-agent -s`
|
||||
- travis/setup-secure-shell.sh
|
||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' ]; then travis/install-php-extensions.sh; fi"
|
||||
|
@ -188,7 +188,7 @@ class RSA
|
||||
/**
|
||||
* PKCS#8 formatted private key
|
||||
*/
|
||||
const PRIVATE_FORMAT_PKCS8 = 3;
|
||||
const PRIVATE_FORMAT_PKCS8 = 8;
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
|
@ -812,7 +812,28 @@ class BigInteger
|
||||
*/
|
||||
function __debugInfo()
|
||||
{
|
||||
return array('value' => '0x' . $this->toHex(true));
|
||||
$opts = array();
|
||||
switch (MATH_BIGINTEGER_MODE) {
|
||||
case self::MODE_GMP:
|
||||
$engine = 'gmp';
|
||||
break;
|
||||
case self::MODE_BCMATH:
|
||||
$engine = 'bcmath';
|
||||
break;
|
||||
case self::MODE_INTERNAL:
|
||||
$engine = 'internal';
|
||||
$opts[] = PHP_INT_SIZE == 8 ? '64-bit' : '32-bit';
|
||||
}
|
||||
if (MATH_BIGINTEGER_MODE != self::MODE_GMP && defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
|
||||
$opts[] = 'OpenSSL';
|
||||
}
|
||||
if (!empty($opts)) {
|
||||
$engine.= ' (' . implode($opts, ', ') . ')';
|
||||
}
|
||||
return array(
|
||||
'value' => '0x' . $this->toHex(true),
|
||||
'engine' => $engine
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2862,6 +2862,17 @@ class SSH2
|
||||
return (bool) ($this->bitmap & self::MASK_CONNECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Have you successfully been logged in?
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function isAuthenticated()
|
||||
{
|
||||
return (bool) ($this->bitmap & self::MASK_LOGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Binary Packets
|
||||
*
|
||||
|
@ -34,6 +34,11 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
||||
'Failed asserting that SSH2 is not connected after construction.'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$ssh->isAuthenticated(),
|
||||
'Failed asserting that SSH2 is not authenticated after construction.'
|
||||
);
|
||||
|
||||
$this->assertNotEmpty(
|
||||
$ssh->getServerPublicHostKey(),
|
||||
'Failed asserting that a non-empty public host key was fetched.'
|
||||
@ -55,6 +60,31 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
||||
/**
|
||||
* @depends testPreLogin
|
||||
*/
|
||||
public function testBadPassword($ssh)
|
||||
{
|
||||
$username = $this->getEnv('SSH_USERNAME');
|
||||
$password = $this->getEnv('SSH_PASSWORD');
|
||||
$this->assertFalse(
|
||||
$ssh->login($username, 'zzz' . $password),
|
||||
'SSH2 login using password succeeded.'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ssh->isConnected(),
|
||||
'Failed asserting that SSH2 is connected after bad login attempt.'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$ssh->isAuthenticated(),
|
||||
'Failed asserting that SSH2 is not authenticated after bad login attempt.'
|
||||
);
|
||||
|
||||
return $ssh;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testBadPassword
|
||||
*/
|
||||
public function testPasswordLogin($ssh)
|
||||
{
|
||||
$username = $this->getEnv('SSH_USERNAME');
|
||||
@ -64,6 +94,11 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
||||
'SSH2 login using password failed.'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ssh->isAuthenticated(),
|
||||
'Failed asserting that SSH2 is authenticated after good login attempt.'
|
||||
);
|
||||
|
||||
return $ssh;
|
||||
}
|
||||
|
||||
|
@ -355,4 +355,15 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
|
||||
'Failed asserting that Alice and Bob share the same BigInteger.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.6
|
||||
*/
|
||||
public function testDebugInfo()
|
||||
{
|
||||
$num = $this->getInstance(50);
|
||||
$str = print_r($num, true);
|
||||
$this->assertContains('[value] => 0x32', $str);
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,5 @@ function install_php_extension
|
||||
}
|
||||
|
||||
# runkit
|
||||
if [ "$TRAVIS_PHP_VERSION" == "5.6" ]
|
||||
then
|
||||
git clone https://github.com/adrianguenter/runkit.git
|
||||
else
|
||||
git clone https://github.com/zenovich/runkit.git
|
||||
fi
|
||||
git clone https://github.com/zenovich/runkit.git
|
||||
install_php_extension 'runkit'
|
||||
|
Loading…
Reference in New Issue
Block a user