mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-12 09:09:39 +01:00
Merge branch 'master' into php5
* master: Mark SSH2 Test as Incomplete on Travis PHP 5.3.3 and below for now. Add basic SSH2 functional test as an example. Extract phpunit call to run-phpunit.sh Introduce abstract class for functional tests.
This commit is contained in:
commit
d2d3c4605d
@ -15,13 +15,14 @@ env:
|
|||||||
- secure: "jtQTZKQBnzUlp/jz7NlM6470ZDnLGVAs53sgvIm4tcYqf9TWSXSXjIYvFsrS\nKPR2eyZaAevYysUkIGRFTUXTlG6tC36YngMp9+6FPxASl8mnGXsTbKcm613B\n59vD3242pgIgqhhmgFQ0c8gbvnE8PuF2aS4/hluP3r+AxhWN56E="
|
- secure: "jtQTZKQBnzUlp/jz7NlM6470ZDnLGVAs53sgvIm4tcYqf9TWSXSXjIYvFsrS\nKPR2eyZaAevYysUkIGRFTUXTlG6tC36YngMp9+6FPxASl8mnGXsTbKcm613B\n59vD3242pgIgqhhmgFQ0c8gbvnE8PuF2aS4/hluP3r+AxhWN56E="
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- travis/setup-secure-shell.sh
|
||||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then travis/install-php-extensions.sh; fi"
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then travis/install-php-extensions.sh; fi"
|
||||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then composer install --dev --no-interaction; fi"
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then composer install --dev --no-interaction; fi"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset.xml phpseclib/; fi"
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset.xml phpseclib/; fi"
|
||||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset-tests.xml tests/; fi"
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset-tests.xml tests/; fi"
|
||||||
- phpunit --verbose --coverage-text --coverage-html code_coverage/
|
- travis/run-phpunit.sh
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then travis/upload-code-coverage.sh; fi"
|
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then travis/upload-code-coverage.sh; fi"
|
||||||
|
45
tests/Net/SSH2FunctionalTest.php
Normal file
45
tests/Net/SSH2FunctionalTest.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andreas Fischer <bantu@phpbb.com>
|
||||||
|
* @copyright MMXIV Andreas Fischer
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Net_SSH2FunctionalTest extends PhpseclibFunctionalTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
if (getenv('TRAVIS') && version_compare(PHP_VERSION, '5.3.3', '<=')) {
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test hangs on Travis CI on PHP 5.3.3 and below.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConstructor()
|
||||||
|
{
|
||||||
|
$ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME'));
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
is_object($ssh),
|
||||||
|
'Could not construct NET_SSH2 object.'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $ssh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConstructor
|
||||||
|
*/
|
||||||
|
public function testPasswordLogin($ssh)
|
||||||
|
{
|
||||||
|
$username = $this->getEnv('SSH_USERNAME');
|
||||||
|
$password = $this->getEnv('SSH_PASSWORD');
|
||||||
|
$this->assertTrue(
|
||||||
|
$ssh->login($username, $password),
|
||||||
|
'SSH2 login using password failed.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
47
tests/PhpseclibFunctionalTestCase.php
Normal file
47
tests/PhpseclibFunctionalTestCase.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Andreas Fischer <bantu@phpbb.com>
|
||||||
|
* @copyright MMXIV Andreas Fischer
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $variable
|
||||||
|
* @param string|null $message
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
protected function requireEnv($variable, $message = null)
|
||||||
|
{
|
||||||
|
if ($this->_getEnv($variable) === false) {
|
||||||
|
$msg = $message ? $message : sprintf(
|
||||||
|
"This test requires the '%s' environment variable.",
|
||||||
|
$this->_prefixEnvVariable($variable)
|
||||||
|
);
|
||||||
|
$this->markTestSkipped($msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $variable
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getEnv($variable)
|
||||||
|
{
|
||||||
|
$this->requireEnv($variable);
|
||||||
|
return $this->_getEnv($variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getEnv($variable)
|
||||||
|
{
|
||||||
|
return getenv($this->_prefixEnvVariable($variable));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _prefixEnvVariable($variable)
|
||||||
|
{
|
||||||
|
return 'PHPSECLIB_' . $variable;
|
||||||
|
}
|
||||||
|
}
|
12
travis/run-phpunit.sh
Executable file
12
travis/run-phpunit.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
export PHPSECLIB_SSH_HOSTNAME='localhost'
|
||||||
|
export PHPSECLIB_SSH_USERNAME='phpseclib'
|
||||||
|
export PHPSECLIB_SSH_PASSWORD='EePoov8po1aethu2kied1ne0'
|
||||||
|
|
||||||
|
phpunit \
|
||||||
|
--verbose \
|
||||||
|
--coverage-text \
|
||||||
|
--coverage-html code_coverage/
|
17
travis/setup-secure-shell.sh
Executable file
17
travis/setup-secure-shell.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This file is part of the phpseclib project.
|
||||||
|
#
|
||||||
|
# (c) Andreas Fischer <bantu@phpbb.com>
|
||||||
|
#
|
||||||
|
# For the full copyright and license information, please view the LICENSE
|
||||||
|
# file that was distributed with this source code.
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
USERNAME='phpseclib'
|
||||||
|
PASSWORD='EePoov8po1aethu2kied1ne0'
|
||||||
|
|
||||||
|
sudo useradd "$USERNAME"
|
||||||
|
echo "$USERNAME:$PASSWORD" | sudo chpasswd
|
Loading…
Reference in New Issue
Block a user