Example #1
0
 /**
  * Test setServer
  *
  * @return void
  */
 public function testSetServer()
 {
     $addr = '127.0.0.1';
     $port = '49';
     $secret = 'secret';
     $cli = new Client();
     $cli->setServer($addr, $port, $secret);
     $obj = new ReflectionClass('\\TACACS\\Client');
     $addrProp = $obj->getProperty('addr');
     $addrProp->setAccessible(true);
     $this->assertEquals($addr, $addrProp->getValue($cli));
     $portProp = $obj->getProperty('port');
     $portProp->setAccessible(true);
     $this->assertEquals($port, $portProp->getValue($cli));
     $secretProp = $obj->getProperty('secret');
     $secretProp->setAccessible(true);
     $this->assertEquals($secret, $secretProp->getValue($cli));
 }
Example #2
0
*
* @category Authentication
* @package  TacacsPlus
* @author   Martín Claro <*****@*****.**>
* @license  http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link     https://github.com/martinclaro
*/
error_reporting(E_ALL);
set_time_limit(0);
ob_implicit_flush();
require_once __DIR__ . '/../vendor/autoload.php';
use TACACS\Client;
use Monolog\Logger;
// RUNTIME
$tacacs_server_addr = '127.0.0.1';
$tacacs_server_port = 4949;
$tacacs_server_secret = 'testing123';
$tacacs_user_username = '******';
$tacacs_user_password = '******';
$tacacs_user_port = 'http';
$tacacs_user_remote_addr = '192.168.197.122';
$logger = new Logger('tacacs');
$srv = new Client($logger);
$srv->setServer($tacacs_server_addr, $tacacs_server_port, $tacacs_server_secret);
$srv->setTimeout(1.5);
$res = $srv->authenticate($tacacs_user_username, $tacacs_user_password, $tacacs_user_port, $tacacs_user_remote_addr);
if ($res) {
    echo "\nAUTHENTICATION SUCCESS!\n\n";
} else {
    echo "\nAUTHENTICATION FAILED!\n\n";
}