]>
git.defcon.no Git - hermes/blob - api/t/phone.t
4 use Test
::More
'no_plan';
8 # Configuration variables defined in tests_common
9 # Make sure those are updated/set correctly..
13 # Further variables defined in tests_common:
19 my ($data, $temp, $test_domain);
21 my $test_macaddress = '12341d6db76c';
23 isa_ok
( $g_ua, 'LWP::UserAgent', '$g_ua');
24 isa_ok
( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
28 # First: fetch a supported domain from the API...
29 $data = exec_apinode
("domain/list", undef);
30 ok
($data, 'domain/list JSON decode');
31 is
( $data->{'response'}, 'ok', 'domain/list result');
32 ok
($data->{'list'}, 'domain/list array');
34 # NOW: Set the $test_domain to something useful (i.e. the first reported domain)
35 $test_domain = $data->{'list'}[0];
37 ok
($test_domain, 'test_domain set.');
40 $data = exec_apinode
("user/available", { "user" => $test_username . "\@" . $test_domain });
41 is
( $data->{'response'}, 'ok', 'user/available is available');
44 $data = exec_apinode
("user/add_local", {
45 "user" => $test_username . "\@" . $test_domain,
46 "displayname" => "Automatic testing",
47 "email" => "noreply\@" . $test_domain,
49 is
( $data->{'response'}, 'ok', 'user/add_local created new account');
51 $data = exec_apinode
("phone/list", undef);
52 is
( $data->{'response'}, 'ok', 'phone/list result');
53 ok
($data->{'list'}, 'phone/list array');
56 $data = exec_apinode
("phone/add", {
57 'user' => $test_username . "\@" . $test_domain,
58 'mac' => $test_macaddress,
61 is
( $data->{'response'}, 'ok', 'phone/add result');
62 ok
($data->{'mac'}, 'phone/add mac set');
63 ok
($data->{'username'}, 'phone/add username set');
64 ok
($data->{'domain'}, 'phone/add domain set');
67 $data = exec_apinode
("phone/list", { 'search' => $test_macaddress });
68 is
( $data->{'response'}, 'ok', 'phone/list search result');
69 ok
($data->{'list'}, 'phone/list search array');
70 print Dumper
($data->{'list'});
74 $data = exec_apinode
("phone/get", { 'mac' => $test_macaddress });
75 is
( $data->{'response'}, 'ok', 'phone/get mac result');
76 ok
($data->{'list'}, 'phone/get mac array');
79 $data = exec_apinode
("phone/get", { 'user' => $test_username . "\@" . $test_domain });
80 is
( $data->{'response'}, 'ok', 'phone/get user result');
81 ok
($data->{'list'}, 'phone/get user array');
84 $data = exec_apinode
("phone/remove", {
85 'user' => $test_username . "\@" . $test_domain,
86 'mac' => $test_macaddress,
88 is
( $data->{'response'}, 'ok', 'phone/remove result');
89 ok
($data->{'mac'}, 'phone/remove mac set');
90 ok
($data->{'username'}, 'phone/remove username set');
91 ok
($data->{'domain'}, 'phone/remove domain set');
94 $data = exec_apinode
("user/remove", { "user" => $test_username . "\@" . $test_domain });
95 is
( $data->{'response'}, 'ok', 'user/remove deleted user');