]>
git.defcon.no Git - hermes/blob - api/t/domain.t
3 use Test
::More
'no_plan';
10 my $api_base = "http://10.0.2.5/hermes/api/";
11 my $api_key = "6327c08b70f9";
12 my $api_user = "test";
13 my $api_pass = "Very5ecr3t";
15 my $test_domain = "example.com"; #TODO: Must fetch this from API
18 my ($g_ua, $response, $data, $temp);
21 $g_ua = LWP
::UserAgent
->new;
22 isa_ok
( $g_ua, 'LWP::UserAgent', '$g_ua');
24 $g_ua->cookie_jar({}); # In-memory jar, look at HTTP::Cookies for persistant
25 isa_ok
( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
28 local $TODO = 'auth/login not implemented yet';
29 $response = $g_ua->get( $api_base . "auth/login?username=" . $api_user .
30 "password=" . $api_pass . "&key=" . $api_key);
32 #$data = decode_json( $response->content);
33 is
( $data->{'response'}, 'ok', 'auth/login');
34 undef $response; undef $data;
37 $response = $g_ua->get( $api_base . "domain/list");
38 isa_ok
( $response, 'HTTP::Response', 'domain/list $response');
39 ok
($response->is_success, 'domain/list is_success');
40 $data = decode_json
( $response->content);
41 ok
($data, 'domain/list JSON decode');
42 is
( $data->{'response'}, 'ok', 'domain/list result');
43 ok
($data->{'list'}, 'domain/list array');
44 undef $response; undef $data;
47 local $TODO = 'not implemented yet';
48 $response = $g_ua->get( $api_base . "domain/get_servers");
49 isa_ok
( $response, 'HTTP::Response', 'domain/list $response');
50 ok
($response->is_success, 'domain/list is_success');
51 $data = decode_json
( $response->content);
52 ok
($data, 'domain/get_servers JSON decode');
53 is
( $data->{'response'}, 'ok', 'domain/get_servers result');
54 ok
($data->{'server'}->{'domain'}, 'domain/get_servers - domain');
55 ok
($data->{'server'}->{'registrar'}, 'domain/get_servers - registrar');
56 ok
($data->{'server'}->{'r_port'}, 'domain/get_servers - r_port');
57 ok
($data->{'server'}->{'proxy'}, 'domain/get_servers - proxy');
58 ok
($data->{'server'}->{'p_port'}, 'domain/get_servers - p_port');
59 ok
($data->{'server'}->{'prov_url'}, 'domain/get_servers - prov_url');
60 undef $response; undef $data;
65 local $TODO = 'not implemented yet';
66 $response = $g_ua->get( $api_base . "domain/set_servers" .
67 "?domain=" . $test_domain . # TODO This should be fetched from domain/list !!
68 "®istrar=registrar." . $test_domain .
70 "&proxy=proxy." . $test_domain .
72 "&prov_url=http://phone." . $test_domain );
74 isa_ok
( $response, 'HTTP::Response', 'domain/list $response');
75 ok
($response->is_success, 'domain/list is_success');
76 $data = decode_json
( $response->content);
77 ok
($data, 'domain/get_servers JSON decode');
78 is
( $data->{'response'}, 'ok', 'domain/get_servers result');
79 ok
($data->{'server'}->{'domain'}, 'domain/get_servers - domain');
80 ok
($data->{'server'}->{'registrar'}, 'domain/get_servers - registrar');
81 ok
($data->{'server'}->{'r_port'}, 'domain/get_servers - r_port');
82 ok
($data->{'server'}->{'proxy'}, 'domain/get_servers - proxy');
83 ok
($data->{'server'}->{'p_port'}, 'domain/get_servers - p_port');
84 ok
($data->{'server'}->{'prov_url'}, 'domain/get_servers - prov_url');
85 undef $response; undef $data;