1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl Net-XRC.t'
4 #########################
6 # change 'tests => 1' to 'tests => last_test_to_print';
9 #BEGIN { plan tests => 3 };
11 use Test::More tests => 17;
12 BEGIN{ use_ok('Net::XRC', qw(:types)) }
14 #########################
16 # Insert your test code below, the Test::More module is use()ed here so read
17 # its man page ( perldoc Test::More ) for help writing this test script.
21 my $clientID = '1551978';
22 my $password = 'password';
24 my $xrc = new Net::XRC (
25 'clientID' => $clientID,
26 'password' => $password,
29 my $domain = 'SISD.EVERY1.NET';
34 ok( $res->is_success, 'noop sucessful' )
35 or diag( $res->error );
36 ok( ! defined($res->content), 'noop returns undef' );
38 # lookupMXReadyClientIDByEmailDomain
40 $res = $xrc->lookupMXReadyClientIDByEmailDomain($domain);
41 ok( $res->is_success, 'lookupMXReadyClientIDByEmailDomain sucessful' )
42 or diag( $res->error );
43 my $domain_clientID = $res->content;
44 ok( $domain_clientID != -1, 'lookupMXReadyClientIDByEmailDomain' );
48 my @set = ( 'a'..'z', '0'..'9' );
49 my $username = join('', map { $set[int(rand(scalar(@set)))] } ( 1..32 ) );
50 $res = $xrc->isAccountNameAvailable( $domain_clientID, $username );
51 ok( $res->is_success, 'isAccountName sucessful' )
52 or diag( $res->error );
53 ok( $res->content, 'isAccountName returns true' );
55 # isAccountName (numeric)
57 my @nset = ( '0'..'9' );
58 my $nusername = join('', map { $nset[int(rand(scalar(@nset)))] } ( 1..32 ) );
59 $res = $xrc->isAccountNameAvailable( $domain_clientID, string($nusername) );
60 ok( $res->is_success, 'isAccountName (numeric) sucessful' )
61 or diag( $res->error );
62 ok( $res->content, 'isAccountName (numeric) returns true' );
66 $res = $xrc->createUser( $domain_clientID, [], $username, 'password' );
67 ok( $res->is_success, 'createUser sucessful' )
68 or diag( $res->error );
69 ok( $res->content, 'createUser returns uid' );
71 # createUser (numeric)
73 $res = $xrc->createUser( $domain_clientID, [], string($nusername), 'password' );
74 ok( $res->is_success, 'createUser (numeric) sucessful' )
75 or diag( $res->error );
76 ok( $res->content, 'createUser (numeric) returns uid' );
81 $res = $xrc->setUserPassword ( $domain_clientID, $username, 'newpassword' );
82 ok( $res->is_success, 'setUserPassword sucessful' )
83 or diag( $res->error );
87 $res = $xrc->suspendUser( $domain_clientID, $username );
88 ok( $res->is_success, 'suspendUser sucessful' )
89 or diag( $res->error );
93 $res = $xrc->unsuspendUser( $domain_clientID, $username );
94 ok( $res->is_success, 'unsuspendUser sucessful' )
95 or diag( $res->error );
100 $res = $xrc->deleteUser( $domain_clientID, $username );
101 ok( $res->is_success, 'deleteUser sucessful' )
102 or diag( $res->error );