示例#1
0
 /**
  * Initialization of tests definitions
  * 
  * @since GIT: 0.1.0
  * @version GIT: 0.1.0
  */
 public function setUp()
 {
     global $data;
     $this->data = $data;
     $ipa = new \FreeIPA\APIAccess\Main($data['host'], $data['cert']);
     $r = $ipa->connection()->authenticate($data['user'], $data['pass']);
     if (false === $r) {
         $this->markTestIncomplete('This test need a connection with the server');
     }
     $this->setInstance($ipa);
 }
示例#2
0
$random = rand(1, 9999);
require_once '../bootstrap.php';
try {
    $ipa = new \FreeIPA\APIAccess\Main($host, $certificate);
    //$ipa->connection($host, $certificate);
} catch (Exception $e) {
    _print("[instance] Exception. Message: {$e->getMessage()} Code: {$e->getCode()}");
    die;
}
// If you wish to force the use of one specific version of API (for example:
// after make tests in the code and define that he does not work with different
// versions).
//$ipa->connection()->setAPIVersion('2.112');
// Make authentication
try {
    $ret_aut = $ipa->connection()->authenticate($user, $password);
    if (TRUE === $ret_aut) {
        // user is authenticate
        _print('Authentication successful');
    } else {
        $auth_info = $ipa->connection()->getAuthenticationInfo();
        var_dump($auth_info);
        // For more details:
        //$ret_curl = $ipa->connection()->getCurlError();
        //print "User is not authenticated. Return is: <br/>" . PHP_EOL;
        //print "cURL: " . $ret_curl[0] . " (" . $ret_curl[1] . ")<br/>" . PHP_EOL;
        //print "cURL string: " . $ipa->connection()->getCurlReturn() . "<br/>\n";
        die;
    }
} catch (Exception $e) {
    _print("[login] Exception. Message: {$e->getMessage()} Code: {$e->getCode()}");