Add basic SSH2 functional test as an example.

This commit is contained in:
Andreas Fischer 2014-03-03 01:43:58 +01:00
parent dbcba51198
commit 00c19f4cc1
4 changed files with 57 additions and 0 deletions

View File

@ -16,6 +16,7 @@ env:
- secure: "jtQTZKQBnzUlp/jz7NlM6470ZDnLGVAs53sgvIm4tcYqf9TWSXSXjIYvFsrS\nKPR2eyZaAevYysUkIGRFTUXTlG6tC36YngMp9+6FPxASl8mnGXsTbKcm613B\n59vD3242pgIgqhhmgFQ0c8gbvnE8PuF2aS4/hluP3r+AxhWN56E="
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' = '5.5' ]; then composer install --dev --no-interaction; fi"

View File

@ -0,0 +1,35 @@
<?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 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.'
);
}
}

View File

@ -2,6 +2,10 @@
set -e
set -x
export PHPSECLIB_SSH_HOSTNAME='localhost'
export PHPSECLIB_SSH_USERNAME='phpseclib'
export PHPSECLIB_SSH_PASSWORD='EePoov8po1aethu2kied1ne0'
phpunit \
--verbose \
--coverage-text \

17
travis/setup-secure-shell.sh Executable file
View 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