gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

commit e5580283bc01e53717018d066edd4df2bcccc613
parent a2067b943aa0e08c3e2c04f0bd9167f183574d49
Author: Marcel <info@nordgedanken.de>
Date:   Sat, 24 Oct 2015 11:03:44 +0200

update tests

Diffstat:
Mbackend/getNodes.sh | 0
Mindex.php | 2+-
MindexClass.php | 18+++++++++++-------
Mnodes/communities.json | 4++--
Anodes/nodesFFFL.json | 0
Mnodes/nodesFFKI.json | 0
Mnodes/nodesFFKI_schoen.json | 0
Mphpunit.xml | 33+++++++++++++++++++++++++++++++--
Mtests/bootstrap.php | 12++++++++++++
9 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/backend/getNodes.sh b/backend/getNodes.sh diff --git a/index.php b/index.php @@ -72,7 +72,7 @@ include "indexClass.php"; <h1 class="header">Welcome to the Gluon Admin</h1> <p> <?php - main::openConnection("ls -la", "root", "xxxx", "tarp1", "FFKI"); + main::openConnection("ls -la", "root", "xxxx", "Angeln0009", "FFFL"); ?> </p> </div> diff --git a/indexClass.php b/indexClass.php @@ -19,7 +19,7 @@ class main { $nodes = file_get_contents($communityURL); //$nodes = file_get_contents("http://map.ffki.de/nodes.json"); - $nodes_file = fopen("nodes/nodes"+$communityID+".json", "w+") or die("Unable to open file!"); + $nodes_file = fopen("nodes/nodes".$communityID.".json", "w+") or die("Unable to open file!"); //$nodes_file = fopen("nodes/nodesFFKI.json", "w+") or die("Unable to open file!"); fwrite($nodes_file, $nodes); fclose($nodes_file); @@ -32,8 +32,8 @@ class main { function parseMAC($nodeName, $communityID){ main::getNodes($communityID); - //$nodes_string = file_get_contents("nodes/nodes"+$communityID+".json"); - $nodes_str = file_get_contents("nodes/nodesFFKI.json"); + $nodes_string = file_get_contents("nodes/nodes".$communityID.".json"); + //$nodes_str = file_get_contents("nodes/nodesFFKI.json"); $json_nodes = json_decode($nodes_str); foreach($json_nodes->nodes as $nodes){ if($nodes->name == $nodeName){ @@ -61,8 +61,12 @@ class main { $prefix = main::getV6Prefix($communityID); $mac_array = explode(":", $mac); - $host_id = ":".$mac_array[0].$mac_array[1].":".$mac_array[2]."ff:fe".$mac_array[3].":".$mac_array[4].$mac_array[5]; - $ipv6 = $prefix."0".$host_id; + if(!empty($mac)){ + if(!empty($prefix)){ + $host_id = ":".$mac_array[0].$mac_array[1].":".$mac_array[2]."ff:fe".$mac_array[3].":".$mac_array[4].$mac_array[5]; + $ipv6 = $prefix."0".$host_id; + } + } return $ipv6; } @@ -73,8 +77,8 @@ class main { function openConnection($command, $user, $password, $nodeName, $communityID){ $ip = main::genV6($nodeName, $communityID); - if(helper::pingPortOnServer($ip,"22") == 1){ - $localhost = new Ssh\Configuration($ip); + if(helper::pingPortOnServer("[".$ip."]","22") == 1){ + $localhost = new Ssh\Configuration("[".$ip."]"); $authentication = new Ssh\Authentication\Password($user, $password); $session = new Ssh\Session($ssh, $authentication); $exec = $session->getExec(); diff --git a/nodes/communities.json b/nodes/communities.json @@ -5,7 +5,7 @@ "v6": "fda1:384a:74de:", "v6mask": "/48", "v4": "10.116.0.0", - "v4mask": "/16"- + "v4mask": "/16" }, "FFFL": { "name": "Freifunk Flensburg", @@ -13,6 +13,6 @@ "v6": "fddf:bf7:10:1:", "v6mask": "/64", "v4": "10.129.0.0", - "v4mask": "/16"- + "v4mask": "/16" } } diff --git a/nodes/nodesFFFL.json b/nodes/nodesFFFL.json diff --git a/nodes/nodesFFKI.json b/nodes/nodesFFKI.json diff --git a/nodes/nodesFFKI_schoen.json b/nodes/nodesFFKI_schoen.json diff --git a/phpunit.xml b/phpunit.xml @@ -1,7 +1,36 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit bootstrap="tests/bootstrap.php" colors="true" verbose="true"> - <testsuite name="mysqliLoadedTest"> +<phpunit backupGlobals="false" + backupStaticAttributes="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + processIsolation="false" + stopOnFailure="false" + syntaxCheck="false" + bootstrap="tests/bootstrap.php" + verbose="true" +> + <testsuite name="Main Tests"> <file>tests/indexClassTest.php</file> </testsuite> + + <testsuites> + <testsuite name="SSH Library Test Suite"> + <directory>libs/php-ssh/tests</directory> + </testsuite> + </testsuites> + + <filter> + <whitelist> + <directory>libs/php-ssh/src/Ssh</directory> + </whitelist> + </filter> + + <groups> + <exclude> + <group>functional</group> + </exclude> + </groups> </phpunit> diff --git a/tests/bootstrap.php b/tests/bootstrap.php @@ -1,3 +1,15 @@ <?php include_once('AutoLoader.php'); AutoLoader::registerDirectory('tests'); + +$filename = __DIR__.'libs/php-ssh/vendor/autoload.php'; + +if (!file_exists($filename)) { + echo 'You must first install the vendors using composer.'.PHP_EOL; + exit(1); +} + +define('TEST_USER', get_current_user()); +define('TEST_PASSWORD', '1234'); + +require_once $filename;