|
|
@ -2,14 +2,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
require_once('common.php');
|
|
|
|
require_once('common.php');
|
|
|
|
|
|
|
|
|
|
|
|
require_once('simpletest/unit_tester.php');
|
|
|
|
require_once('PHPUnit/Autoload.php');
|
|
|
|
|
|
|
|
|
|
|
|
require_once('Zend/XmlRpc/Client.php');
|
|
|
|
require_once('Zend/XmlRpc/Client.php');
|
|
|
|
require_once('Zend/Http/Client.php');
|
|
|
|
require_once('Zend/Http/Client.php');
|
|
|
|
require_once('Zend/Registry.php');
|
|
|
|
require_once('Zend/Registry.php');
|
|
|
|
|
|
|
|
|
|
|
|
class RemoteTest extends UnitTestCase {
|
|
|
|
abstract class RemoteTest extends PHPUnit_Framework_TestCase {
|
|
|
|
|
|
|
|
|
|
|
|
protected $server_url = 'http://orange/david/postfixadmin/trunk/xmlrpc.php';
|
|
|
|
protected $server_url = 'http://orange/david/postfixadmin/xmlrpc.php';
|
|
|
|
protected $username = 'roger@example.com';
|
|
|
|
protected $username = 'roger@example.com';
|
|
|
|
protected $password = 'patchthedog';
|
|
|
|
protected $password = 'patchthedog';
|
|
|
|
|
|
|
|
|
|
|
@ -18,45 +19,8 @@ class RemoteTest extends UnitTestCase {
|
|
|
|
protected $vacation;
|
|
|
|
protected $vacation;
|
|
|
|
protected $alias;
|
|
|
|
protected $alias;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
|
|
// ensure a user exists as per the above...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$table_vacation = table_by_key('vacation');
|
|
|
|
|
|
|
|
$table_alias = table_by_key('alias');
|
|
|
|
|
|
|
|
$table_mailbox = table_by_key('mailbox');
|
|
|
|
|
|
|
|
$table_domain = table_by_key('domain');
|
|
|
|
|
|
|
|
$username = escape_string($this->username);
|
|
|
|
|
|
|
|
$password = escape_string(pacrypt($this->password));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db_query("DELETE FROM $table_vacation WHERE email = '$username'");
|
|
|
|
|
|
|
|
db_query("DELETE FROM $table_alias WHERE domain = 'example.com'");
|
|
|
|
|
|
|
|
db_query("DELETE FROM $table_mailbox WHERE domain = 'example.com'");
|
|
|
|
|
|
|
|
db_query("DELETE FROM $table_domain WHERE domain = 'example.com'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create new db records..
|
|
|
|
|
|
|
|
$result = db_query("INSERT INTO $table_domain (domain, aliases, mailboxes) VALUES ('example.com', 100, 100)");
|
|
|
|
|
|
|
|
if($result['rows'] != 1) {
|
|
|
|
|
|
|
|
die("Failed to add domain to db....");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query("INSERT INTO $table_mailbox (username, password, name, local_part, domain) VALUES ('$username', '$password', 'test user', 'roger', 'example.com')");
|
|
|
|
|
|
|
|
if($result['rows'] != 1) {
|
|
|
|
|
|
|
|
die("Failed to add user to db....");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query("INSERT INTO $table_alias (address, goto, domain) VALUES ('$username', '$username', 'example.com')");
|
|
|
|
|
|
|
|
if($result['rows'] != 1) {
|
|
|
|
|
|
|
|
die("Failed to add alias to db....");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
$this->xmlrpc_client = new Zend_XmlRpc_Client($this->server_url);
|
|
|
|
$this->xmlrpc_client = new Zend_XmlRpc_Client($this->server_url);
|
|
|
|
$http_client = $this->xmlrpc_client->getHttpClient();
|
|
|
|
$http_client = $this->xmlrpc_client->getHttpClient();
|
|
|
|
$http_client->setCookieJar();
|
|
|
|
$http_client->setCookieJar();
|
|
|
@ -68,16 +32,6 @@ class RemoteTest extends UnitTestCase {
|
|
|
|
var_dump($success);
|
|
|
|
var_dump($success);
|
|
|
|
die("Failed to login to xmlrpc interface");
|
|
|
|
die("Failed to login to xmlrpc interface");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->user = $this->xmlrpc_client->getProxy('user');
|
|
|
|
|
|
|
|
$this->alias = $this->xmlrpc_client->getProxy('alias');
|
|
|
|
|
|
|
|
$this->vacation = $this->xmlrpc_client->getProxy('vacation');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(Exception $e) {
|
|
|
|
|
|
|
|
var_dump($e);
|
|
|
|
|
|
|
|
var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
|
|
|
|
|
|
|
|
die("Error setting up..");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|