]> git.defcon.no Git - hermes/blob - api/t/domain.t
69882035b81f896bdb7d612ad8bc740cf212025d
[hermes] / api / t / domain.t
1 #!/usr/bin/perl
2
3 use strict;
4 use Test::More 'no_plan';
5 use tests_common;
6
7 # Configuration variables defined in tests_common
8 # Make sure those are updated/set correctly..
9 # $api_base
10 # $api_key
11 #
12 # Further variables defined in tests_common:
13 # $invalid_key
14 # $test_username
15 # $test_password
16 # $invalid_username
17
18 my ($data, $temp, $test_domain, $test_remote_domain );
19
20 isa_ok( $g_ua, 'LWP::UserAgent', '$g_ua');
21 isa_ok( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
22
23 login_apikey();
24
25 $data = exec_apinode("domain/list", undef);
26 is( $data->{'response'}, 'ok', 'domain/list result');
27 ok($data->{'list'}, 'domain/list array');
28
29 # NOW: Set the $test_domain to something useful (i.e. the first reported domain)
30 $test_domain = $data->{'list'}[0];
31 ok($test_domain, 'test_domain set.');
32 undef $data;
33
34 $data = exec_apinode("domain/get_servers", { "domain" => $test_domain });
35 is( $data->{'response'}, 'ok', 'domain/get_servers result');
36 ok($data->{'servers'}->{'domain'}, 'domain/get_servers - domain');
37 ok($data->{'servers'}->{'registrar'}, 'domain/get_servers - registrar');
38 ok($data->{'servers'}->{'r_port'}, 'domain/get_servers - r_port');
39 ok($data->{'servers'}->{'proxy'}, 'domain/get_servers - proxy');
40 ok($data->{'servers'}->{'p_port'}, 'domain/get_servers - p_port');
41 ok($data->{'servers'}->{'prov_url'}, 'domain/get_servers - prov_url');
42 undef $data;
43
44 $data = exec_apinode("domain/set_servers", {
45 "domain" => $test_domain,
46 "registrar" => "registrar." . $test_domain,
47 "r_port" => 5060,
48 "proxy" => "proxy." . $test_domain,
49 "p_port" => 5060,
50 "prov_url" => "http://phone." . $test_domain . "/hermes/prov/",
51 } );
52
53 is( $data->{'response'}, 'ok', 'domain/set_servers result');
54 ok($data->{'servers'}->{'domain'}, 'domain/set_servers - domain');
55 ok($data->{'servers'}->{'registrar'}, 'domain/set_servers - registrar');
56 ok($data->{'servers'}->{'r_port'}, 'domain/set_servers - r_port');
57 ok($data->{'servers'}->{'proxy'}, 'domain/set_servers - proxy');
58 ok($data->{'servers'}->{'p_port'}, 'domain/set_servers - p_port');
59 ok($data->{'servers'}->{'prov_url'}, 'domain/set_servers - prov_url');
60 undef $data;
61
62 logout();
63