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

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/API/ISPManager/preset.pm
lib/API/ISPManager/services.pm
lib/API/ISPManager/software.pm
lib/API/ISPManager/stat.pm
lib/API/ISPManager/user.pm
lib/API/ISPManager/vds.pm
lib/API/ISPManager/vdspreset.pm
Makefile.PL
MANIFEST			This list of files
README
runtests.sh
t/01-test.t
t/02-files.t
upload_file.pl
vdsmanager.pl
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

INSTALLTION on Debian

apt-get install libwww-perl make libxml-simple-perl libnet-ssleay-perl libcrypt-ssleay-perl libexporter-lite-perl libtest-simple-perl
cpan API::ISPManager

DEPENDENCIES

This module requires these other modules and libraries:

  blah blah blah

COPYRIGHT AND LICENCE

lib/API/ISPManager/software.pm  view on Meta::CPAN

        allowed_fields => [  qw( host path allow_http    elid ) ],
    );

=head

cost	7.7000
elid	361604
expiredate	2009-10-08
func	software.period
ip	83.222.14.204
licname	testserver1.hosting.reg.ru
payfrom	neworder
period	16
pricename	ISPmanager Pro (without support)
sok	ok

=cut

    return $result;
}

runtests.sh  view on Meta::CPAN

#!/bin/bash

./add_database.pl server5.hosting.reg.ru user_0000434578 oBffquIb db_name111 db_usersss45555 pass
#./add_www_domain.pl server5.hosting.reg.ru user_0000434578 oBffquIb suxx777.us
#./add_mailbox.pl server5.hosting.reg.ru user_0000434578 oBffquIb t1est@server6-host1.regrutestuser.ru qqqq
exit 0

perl -Ilib ./vdsmanager.pl --host=127.0.0.1 --username=admin  --password=qqqq  \
 --nodeid=1 --vpspassword=qwerty --owner=admin --preset=OVZ-1 --os=centos-5-x86_64 \
 --name=mymegavps7.ru

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

use warnings;

use Data::Dumper;

our $ONLINE;

BEGIN {
    $ONLINE = $ENV{password};
}

use Test::More tests => $ONLINE ? 42 : 40;

my $test_host = $ENV{host} || 'ultrasam.ru';

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

$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::ISPManager::mk_query_string( {  }  ), '', $a );
is( API::ISPManager::mk_query_string( ''    ), '', $a );
is( API::ISPManager::mk_query_string( undef ), '', $a );
is( API::ISPManager::mk_query_string( { aaa => 111, bbb => 222 } ), 'aaa=111&bbb=222', $a );
is( API::ISPManager::mk_query_string( { bbb => 222, aaa => 111 } ), 'aaa=111&bbb=222', $a );
is( API::ISPManager::mk_query_string( [ ] ), '', $a );
is( API::ISPManager::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::ISPManager::kill_start_end_slashes ($_),
        $kill_start_end_slashes_test->{$_},
        'kill_start_end_slashes'
    );
}

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

is( API::ISPManager::mk_full_query_string( {
        host       => $test_host,
        allow_http => 1,
        path       => 'manager',
    } ), 
    '',
    $a
);

is(  API::ISPManager::mk_full_query_string( {
        host       => $test_host,
        allow_http => 1,
        path       => '//my_manager///',
        param1     => 'val1',
        param2     => 'val2',
    } ), 
    "http://$test_host/my_manager/ispmgr?param1=val1&param2=val2",
    $a
);

is(  API::ISPManager::mk_full_query_string( {
        host       => $test_host,
        param1     => 'val1',
        param2     => 'val2',
    } ), 
    "https://$test_host/manager/ispmgr?param1=val1&param2=val2",
    $a
);


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

my %correct_params = (
    username => $ENV{username} || 'root',
    password => $ENV{password},
    host     => $test_host,
    path     => 'manager',
);

### Services

my $fake_services = <<DOC;
<?xml version="1.0" encoding="UTF-8"?>
<doc><elem><name>HTTP</name><proc>apache2</proc><autostart/><count>33</count><active/></elem><elem><name>FTP</name><proc>proftpd</proc><autostart/><count>1</count><active/></elem><elem><name>DNS</name><proc>named</proc><autostart/><count>1</count><ac...
DOC

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

                'active' => {}
             },
            'DNS' => {
                'count' => '1',
                'proc' => 'named',
                'autostart' => {},
                'active' => {}
            }
        }
    },
    'services test'
);


### Services end

### Databases

my $fake_db = <<DOC;
<?xml version="1.0" encoding="UTF-8"?>
<doc><elem><dbkey>MySQL-&gt;bt</dbkey><dbtype>MySQL</dbtype><name>bt</name><dbuser>bt</dbuser><owner>bt</owner><size>0.055</size></elem><elem><dbkey>MySQL-&gt;howtouse</dbkey><dbtype>MySQL</dbtype><name>howtouse</name><dbuser>howtouse</dbuser><owner>...

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

            },
            'bt' => {
                'owner'  => 'bt',
                'dbuser' => 'bt',
                'dbtype' => 'MySQL',
                'dbkey'  => 'MySQL->bt',
                'size'   => '0.055'
            }
        }
    },
    'db list test'
);

### Databases end


### DB users

my $fake_db_user = <<DOC;
<?xml version="1.0" encoding="UTF-8"?>
<doc><plid>MySQL-&gt;blog</plid><elem><name>blog</name><read/><write/><manage/></elem></doc>

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


is_deeply(
    API::ISPManager::db_user::list( { %correct_params, elid => 'MySQL->blog' }, $fake_db_user ), {
        'data' => {
            'read' => {},
            'name' => 'blog',
            'manage' => {},
            'write' => {}
        }
    },
    'test db_user'
);


### DB users end

### Stats 

my $fake_sysinfo = <<DOC;
<?xml version="1.0" encoding="UTF-8"?>
<doc><elem><name>cpu</name><value>AMD Athlon(tm) 64 Processor 3700+ 2199.744 Mhz X 2</value></elem><elem><name>mem</name><value>393364 kB</value></elem><elem><name>swap</name><value>999992 kB</value></elem><elem><name>disk</name><value>49385 Mb</valu...

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

        'data' => {
            'proc'   => '88',
            'disk'   => '49385 Mb',
            'cpu'    => 'AMD Athlon(tm) 64 Processor 3700+ 2199.744 Mhz X 2',
            'avg'    => '1.39 0.96 0.89',
            'uptime' => '55 days 14 hours 5 minutes',
            'swap'   => '999992 kB',
            'mem'    => '393364 kB',
        }
    },
    'sysinfo test'
);

my $fake_usagestat = <<DOC;
<?xml version="1.0" encoding="UTF-8"?>
<doc><elem><name>disk</name><value used="1817" limit="4950"/></elem><elem><name>reseller</name><value used="1" limit="0"/></elem><elem><name>user</name><value used="20" limit="0"/></elem><elem><name>bandwidth</name><value used="8170" limit="170000000...
DOC

is_deeply( API::ISPManager::stat::usagestat( { %correct_params }, $fake_usagestat ), {
        'data' => {
            'ftpuser' => {

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

            'reseller' => {
                'used' => '1',
                'limit' => '0'
            },
            'wwwdomain' => {
                'used' => '20',
                'limit' => '70022'
            }
        }
    },
    'usagestat test'
);

### Stats end

#exit;

no warnings 'once';

$API::ISPManager::DEBUG = 0;


### ONLINE TESTS
exit if !$ONLINE;

$a = 'get_auth_id';
is( get_auth_id(
        username => 'root',
        password => 'qwerty',
        host     => $test_host,
        path     => 'manager',
    ), 
    '',
    "$a with error password"
);

my $auth_id;

like( $auth_id = get_auth_id(
        username => $ENV{username} || 'root',
        password => $ENV{password},
        host     => $test_host,
        path     => 'manager',
    ), 
    qr/\d+/,
    "$a with correct password ($auth_id)"
);

=head

is(
    scalar keys %{ API::ISPManager::user::list( { %correct_params } )->{elem} },
    20,
    'user::list test' 
);

=cut

my $ip_list = API::ISPManager::ip::list( { %correct_params } );

diag "Get ips from panel: " . Dumper( $ip_list );

if ($ip_list && ref $ip_list eq 'ARRAY' && scalar @$ip_list) {
    my $ip  = $ip_list->[0];

t/02-files.t  view on Meta::CPAN

use warnings;

use Data::Dumper;

our $ONLINE;


BEGIN {
    $ONLINE = $ENV{host} && $ENV{user} && $ENV{password};
}
use Test::More tests => $ONLINE ? 10 : 2;

my $test_host     = $ENV{host};
my $test_user     = $ENV{user};
my $test_password = $ENV{password};

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

no warnings 'once';

$API::ISPManager::DEBUG = 0;

### ONLINE TESTS
exit if !$ONLINE;

my %connection_params = (
    username => $test_user,
    password => $test_password,
    host     => $test_host,
    path     => 'manager',
);

# Ïîëó÷åíèå ñïèñêà ôàéëîâ
my $file_list_answer = API::ISPManager::file::list( { %connection_params } );
ok($file_list_answer, 'file list');
my @original_file_list = get_file_list('', '');

# Ñîçäàíèå ôàéëà
my $now = time;
my $file_create = API::ISPManager::file::create( {
    %connection_params,
    filetype => 0,
    name => "$now.test",  
    plid => '',  
} );

my @expected_file_list = @original_file_list;
push @expected_file_list, "$now.test";
my @real_file_list = get_file_list('', '');
ok(!union_equal(\@original_file_list, \@real_file_list), 'file creation - check difference exists');
ok(union_equal(\@expected_file_list, \@real_file_list), 'file creation - check created file name');

# Óäàëåíèå ôàéëà
my $file_delete = API::ISPManager::file::delete( {
    %connection_params,
    elid => "$now.test",  
    plid => '',    
} );
@real_file_list = get_file_list('', '');
ok(union_equal(\@original_file_list, \@real_file_list), 'file delete');

# Êîïèðîâàíèå ôàéëà
$now = time;
API::ISPManager::file::create( {
    %connection_params,
    filetype => 0,
    name => "$now.test",  
    plid => '',  
} );

API::ISPManager::file::create( {
    %connection_params,
    filetype => 1,
    name => "$now",  
    plid => '',  
} );

my $file_copy = API::ISPManager::file::copy( {
    %connection_params,
    elid => "$now.test",  
    plid => "$now",
} );

@expected_file_list = ("$now.test");
@real_file_list = get_file_list('', $now);
ok(union_equal(\@expected_file_list, \@real_file_list), 'file copy');

API::ISPManager::file::delete( {
    %connection_params,
    elid => "$now.test",  
    plid => '',    
} );

API::ISPManager::file::delete( {
    %connection_params,
    elid => "$now",  
    plid => '',    
} );

# Ïåðåìåùåíèå ôàéëà
$now = time;
API::ISPManager::file::create( {
    %connection_params,
    filetype => 0,
    name => "$now.test",  
    plid => '',  
} );

API::ISPManager::file::create( {
    %connection_params,
    filetype => 1,
    name => "$now",  
    plid => '',  
} );

my $file_move = API::ISPManager::file::move( {
    %connection_params,
    elid => "$now.test",  
    plid => "$now",
} );

@expected_file_list = ("$now.test");
@real_file_list = get_file_list('', $now);
ok(union_equal(\@expected_file_list, \@real_file_list), 'file move');

API::ISPManager::file::delete( {
    %connection_params,
    elid => "$now",  
    plid => '',    
} );

# Çàãðóçêà ôàéëà



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