Incorrect search filter: invalid characters - *.p[ml]
API-CPanel

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/API/CPanel.pm
lib/API/CPanel/Ip.pm
lib/API/CPanel/Misc.pm
lib/API/CPanel/Package.pm
lib/API/CPanel/User.pm
lib/API/CPanel/Domain.pm
lib/API/CPanel/Mysql.pm
Makefile.PL
MANIFEST			This list of files
README
t/01-test.t
META.yml                                 Module meta-data (added by MakeMaker)

README  view on Meta::CPAN

archive can use it get an idea of the modules uses. It is usually a
good idea to provide version information here so that people can
decide whether fixes for the module are worth downloading.

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

COPYRIGHT AND LICENCE

Put the correct copyright and licence information here.

t/01-test.t  view on Meta::CPAN


use strict;
use warnings;
use lib qw( ./lib );

use Data::Dumper;

our $ONLINE;

BEGIN {
    #$ENV{auth_user}   = 'restest';
    #$ENV{auth_passwd} = '123';
    #$ENV{host}        = '192.168.123.1';
    $ONLINE = $ENV{auth_user} && $ENV{auth_passwd} && $ENV{host};
}

my $manipulate_user = 'zsezse';

use Test::More tests => $ONLINE ? 61 : 61;

my $test_host = $ENV{host} || '127.0.0.1';

ok(1, 'Test OK');
use_ok('API::CPanel');

$a = 'refs';

is( refs( undef ),   '',       $a);
is( refs( {} ),      'HASH',   $a );
is( refs( [] ),      'ARRAY',  $a );
is( refs( sub {} ),  'CODE',   $a );

t/01-test.t  view on Meta::CPAN


$a = 'mk_query_string';
is( API::CPanel::mk_query_string( {  }  ), '', $a );
is( API::CPanel::mk_query_string( ''    ), '', $a );
is( API::CPanel::mk_query_string( undef ), '', $a );
is( API::CPanel::mk_query_string( { aaa => 111, bbb => 222 } ), 'aaa=111&bbb=222', $a );
is( API::CPanel::mk_query_string( { bbb => 222, aaa => 111 } ), 'aaa=111&bbb=222', $a );
is( API::CPanel::mk_query_string( [ ] ), '', $a );
is( API::CPanel::mk_query_string( { dddd => 'dfdf' } ), 'dddd=dfdf', $a );

my $kill_start_end_slashes_test = {
    '////aaa////' => 'aaa',
    'bbb////'     => 'bbb',
    '////ccc'     => 'ccc', 
    ''            => '',
};

for (keys %$kill_start_end_slashes_test) {
    is(
        API::CPanel::kill_start_end_slashes ($_),
        $kill_start_end_slashes_test->{$_},
        'kill_start_end_slashes'
    );
}

$a = 'mk_full_query_string';
is( API::CPanel::mk_full_query_string( {
        host => $test_host, 
    } ), 
    '',
    $a
);

is( API::CPanel::mk_full_query_string( {
        host       => $test_host,
        allow_http => 1,
        path       => 'xml-api',
    } ), 
    '',
    $a
);

is(  API::CPanel::mk_full_query_string( {
        host       => $test_host,
        allow_http => 1,
        param1     => 'val1',
        param2     => 'val2',
        func       => 'test',
    } ), 
    "http://$test_host:2087/xml-api/test?param1=val1&param2=val2",
    $a
);

is(  API::CPanel::mk_full_query_string( {
        host       => $test_host,
        param1     => 'val1',
        param2     => 'val2',
        func       => 'test',
    } ), 
    "https://$test_host:2087/xml-api/test?param1=val1&param2=val2",
    $a
);


$a = 'mk_query_to_server';
is( API::CPanel::mk_query_to_server( '' ), '', $a );

my %correct_params = (
    auth_user   => $ENV{auth_user}   || 'fake',
    auth_passwd => $ENV{auth_passwd} || 'fake_pass',
    host        => $test_host,

);




$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<listips>
  <result>
    <active>1</active>

t/01-test.t  view on Meta::CPAN

my $main_shared_ip = $ip_list->[0];
#diag "Get ips from panel: " . Dumper( $ip_list ) . scalar @$ip_list;
ok($ip_list && ref $ip_list eq 'ARRAY' && scalar @$ip_list, 'API::CPanel::Ip::list');
#$API::CPanel::DEBUG=0;

$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<createacct>
  <result>
    <options>
      <ip>192.168.123.208</ip>
      <nameserver>ns1.centostest.ru</nameserver>
      <nameserver2>ns2.centostest.ru</nameserver2>
      <nameserver3></nameserver3>
      <nameserver4></nameserver4>
      <nameservera></nameservera>
      <nameservera2></nameservera2>
      <nameservera3></nameservera3>
      <nameservera4></nameservera4>
      <nameserverentry></nameserverentry>
      <nameserverentry2></nameserverentry2>
      <nameserverentry3></nameserverentry3>
      <nameserverentry4></nameserverentry4>

t/01-test.t  view on Meta::CPAN

zseasds account has been suspended
</statusmsg>
  </result>
</suspendacct>
THEEND

$result = API::CPanel::User::disable(
    {
	%correct_params,
	user   => $manipulate_user,
	reason => 'test reason1',
    }
);
is( $result, 1, 'API::CPanel::User::disable');

$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<listaccts>
  <acct>
    <disklimit>unlimited</disklimit>
    <diskused>0M</diskused>
    <domain>qewqe.ru</domain>

t/01-test.t  view on Meta::CPAN

    <maxparked>*unknown*</maxparked>
    <maxpop>unlimited</maxpop>
    <maxsql>14</maxsql>
    <maxsub>unlimited</maxsub>
    <owner>root</owner>
    <partition>home</partition>
    <plan>default</plan>
    <shell>/bin/false</shell>
    <startdate>10 Mar 24 11:55</startdate>
    <suspended>1</suspended>
    <suspendreason>test reason1</suspendreason>
    <suspendtime>1269406521</suspendtime>
    <theme>x</theme>
    <unix_startdate>1269406518</unix_startdate>
    <user>zseasd</user>
  </acct>
  <acct>
    <disklimit>unlimited</disklimit>
    <diskused>0M</diskused>
    <domain>zse.ru</domain>
    <email>*unknown*</email>

t/01-test.t  view on Meta::CPAN

Account Already Suspended
</statusmsg>
  </result>
</suspendacct>
THEEND

$result = API::CPanel::User::disable(
    {
	%correct_params,
	user   => $manipulate_user,
	reason => 'test reason2',
    }
);
is( $result, 1, 'API::CPanel::User::disable repeat');

$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<unsuspendacct>
  <result>
    <status>1</status>
    <statusmsg>&lt;script&gt;if (self['clear_ui_status']) { clear_ui_status(); }&lt;/script&gt;
Changing shell for zseasd.

t/01-test.t  view on Meta::CPAN

    <event>
        <result>1</result>
     </event>
</cpanelresult>
THEEND

$result = API::CPanel::Mysql::adduser(
    {
        %correct_params,
        do_as_user => 'zsezse5',
        username   => 'test13',
        password   => 'test13pass',
    }
);
is( $result, 1, 'API::CPanel::Mysql::adduser');

$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
    <module>Mysql</module>
    <func>adddb</func>
    <type>event</type>

t/01-test.t  view on Meta::CPAN

        <result>1</result>
    </event>
</cpanelresult>
THEEND

$result = API::CPanel::Mysql::grant_perms(
    {
        %correct_params,
        do_as_user => 'zsezse5',
        dbname     => 'zsezse5_default',
        dbuser     => 'zsezse5_test13',
        perms_list => 'all',
    }
);
is( $result, 1, 'API::CPanel::Mysql::grant_perms');

$API::CPanel::FAKE_ANSWER = ! $ONLINE ? <<THEEND : undef;
<?xml version="1.0" ?>
<cpanelresult>
  <apiversion>2</apiversion>
  <data>



( run in 0.277 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )