API-PleskExpand
view release on metacpan or search on metacpan
Revision history for Perl extension API::PleskExpand.
1.00 May 25 20:08:15 SAMST 2008
- The first public release
1.01 Jun 1 19:07:04 SAMST 2008
- Fix syntax error in Build.PL :(
- Fix errors in documentation
1.02 Jun 8 13:32:18 SAMST 2008
- Full support all ways of choosing a Plesk server, where the client will be created (autoselect and manual)
1.03 Jun 14 12:16:24 SAMST 2008
- Fix documentation, add tests
1.04 Jun 22 05:21:18 SAMST 2008
- Add ability to attaching domains and accounts to templates
1.05 Jul 29 23:33:12 SAMST 2008
- New function -- get all domains from Expand
1.06 Jul 31 17:34:55 SAMST 2008
- Fixed Build.pl ( Test::LongString not in prereqs_build list but required )
- Add URI.pm as required module
1.07 Sep 12 01:04:09 SAMST 2008
- New function -- get all accounts from Expand
- Fix function "get all domains from Expand" -- bug with one field answer
The given module is intended for interaction with the XML API of the Plesk Expand centralized hosting panel. API is realized not completely, but there is a full support of operations with Account and Domains.
API::PleskExpand module gives the convenient interface for addition of new functions. Extensions represent modules in a folder Expand with definitions of demanded functions. Each demanded operation is described by two functions: op and op_response_pa...
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
TESTS
make test
DEPENDENCIES
This module requires these other modules and libraries:
API::Plesk 1.04,
Carp (standard),
Data::Dumper,
Getopt::Long,
HTTP::Request,
use Carp;
use Test::More;
use Test::LongString;
use Data::Dumper;
use lib 't';
use TestData;
BEGIN {
plan tests => $ENV{online_stress_tests} ? 34 : 28;
use_ok( 'API::PleskExpand' );
use_ok( 'API::PleskExpand::Accounts' );
use_ok( 'API::PleskExpand::Domains' );
use_ok( 'API::Plesk::Response');
}
my $expand_client = API::PleskExpand->new( %TestData::online_expand_valid_params);
isa_ok( $expand_client, 'API::PleskExpand', 'STATIC call new' );
city => '',
state => '',
pcode => '',
country => 'RU',
}
);
my $create_request = API::PleskExpand::Accounts::create( %create_account_data );
is_string($create_request, $_, 'create account test') for
'<add_use_template><gen_info><address></address><city></city><cname></cname>' .
'<country>RU</country><email></email><fax></fax><login>suxdffffxx</login>' .
'<passwd>1234d5678</passwd><pcode></pcode><phone></phone><pname>stdsdffafff</pname>' .
'<state></state><status>0</status></gen_info><!-- create_client -->' .
'<tmpl_id>1</tmpl_id><server_auto><optimal></optimal></server_auto></add_use_template>';
$create_request = API::PleskExpand::Accounts::create(
%create_account_data,
'attach_to_template' => 1
);
is_string($create_request, $_, 'create account test') for
'<add_use_template><gen_info><address></address><city></city><cname></cname>' .
'<country>RU</country><email></email><fax></fax><login>suxdffffxx</login>' .
'<passwd>1234d5678</passwd><pcode></pcode><phone></phone><pname>stdsdffafff</pname>' .
'<state></state><status>0</status></gen_info><!-- create_client -->' .
'<tmpl_id>1</tmpl_id><attach_to_template></attach_to_template><server_auto>' .
'<optimal></optimal></server_auto></add_use_template>';
is_deeply(
API::PleskExpand::Accounts::create( %create_account_data, select => ''),
like(
API::PleskExpand::Accounts::create( %create_account_data, select => 'max_diskspace', server_keyword => 'Hosting'),
qr#<server_auto><max_diskspace></max_diskspace></server_auto><server_keyword>Hosting</server_keyword></add_use_template>$#,
'Select server has "min_domains" with keyword',
);
my $delete_query = API::PleskExpand::Accounts::delete( id => 15 );
is_deeply( $delete_query . "\n", <<DOC, 'delete account test');
<del><!-- del_client --><filter><id>15</id></filter></del>
DOC
my $modify_query = API::PleskExpand::Accounts::modify(
id => 15,
general_info => { status => 16 } # deactivate!
);
is_string( $modify_query, $_, 'modify account test') for
'<set><filter><id>15</id></filter><!-- modify_client --><values>' .
'<gen_info><status>16</status></gen_info></values></set>';
my $modify_query_alter = API::PleskExpand::Accounts::modify(
id => 5,
general_info => { status => 0 } # deactivate!
);
is_string( $modify_query_alter, $_, 'modify account test') for
'<set><filter><id>5</id></filter><!-- modify_client --><values>' .
'<gen_info><status>0</status></gen_info></values></set>';
my %new_domain_data = (
dname => 'y2a1ddsdfandex.ru',
client_id => 16,
'template-id' => 1,
ftp_login => 'nrddgddsdasd',
ftp_password => 'dadsdasd',
);
my $create_domain = API::PleskExpand::Domains::create( %new_domain_data );
is_string( $create_domain, $_, 'modify account test') for
'<add_use_template><gen_setup><name>y2a1ddsdfandex.ru</name>' .
'<client_id>16</client_id><status>0</status></gen_setup>' .
'<hosting><vrt_hst><ftp_login>nrddgddsdasd</ftp_login>' .
'<ftp_password>dadsdasd</ftp_password></vrt_hst></hosting>' .
'<!-- create_domain --><tmpl_id>1</tmpl_id></add_use_template>';
$create_domain = API::PleskExpand::Domains::create( %new_domain_data, attach_to_template => 1 );
is_string( $create_domain, $_, 'modify account test') for
'<add_use_template><gen_setup><name>y2a1ddsdfandex.ru</name>' .
'<client_id>16</client_id><status>0</status></gen_setup>' .
'<hosting><vrt_hst><ftp_login>nrddgddsdasd</ftp_login>' .
'<ftp_password>dadsdasd</ftp_password></vrt_hst></hosting>' .
'<!-- create_domain --><tmpl_id>1</tmpl_id>' .
'<attach_to_template></attach_to_template></add_use_template>';
$expand_client->{dump_headers} = 1; # debugg =)
is_deeply(
$expand_client->_execute_query('<add_use_template><!-- create_domain --></add_use_template>'),
{
':HTTP_AUTH_LOGIN' => $TestData::online_expand_valid_params{'username'},
':HTTP_AUTH_PASSWD' => $TestData::online_expand_valid_params{'password'},
':HTTP_AUTH_OP' => 'exp_plesk_domain'
},
'test request headers'
);
is_deeply(
$expand_client->_execute_query('<add_use_template><!-- create_client --></add_use_template>'),
{
':HTTP_AUTH_LOGIN' => $TestData::online_expand_valid_params{'username'},
':HTTP_AUTH_PASSWD' => $TestData::online_expand_valid_params{'password'},
':HTTP_AUTH_OP' => 'exp_plesk_client'
},
'exp_plesk_client'
'<tmpl_id>1</tmpl_id><expiration>-1</expiration></result></add_use_template></packet>';
is_string(
API::PleskExpand::Domains::get(all => 1),
'<get><filter></filter><dataset><gen_info/></dataset></get><!-- create_domain -->',
'Domains get'
);
exit unless $ENV{'online_stress_tests'};
my ($domain_template_id, $client_template_id);
$domain_template_id = $client_template_id = $ENV{template_id} || 1;
diag "Online tests start!";
# 5 tests -- full set !!!
my $login = $ENV{'online_stress_tests_login'} || 'expandtestaccount';
my $create_account_result = $expand_client->Accounts->create(
'select' => 'optimal',
'template-id' => $client_template_id,
'attach_to_template' => 1,
'general_info' => {
login => $login,
pname => $login,
passwd => 'asdasdasd',
status => 0,
cname => '',
( run in 0.271 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )