]> git.defcon.no Git - hermes/blob - api/t/domain.t
Added license text
[hermes] / api / t / domain.t
1 #!/usr/bin/perl
2 # Copyright (c) 2012, Gjøvik University College
3 # All rights reserved.
4
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # * Neither the name of the Gjøvik University College nor the
13 # names of its contributors may be used to endorse or promote products
14 # derived from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY Gjøvik University College ''AS IS'' AND ANY
17 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 # DISCLAIMED. IN NO EVENT SHALL Gjøvik University College BE LIABLE FOR ANY
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 use strict;
28 use Test::More 'no_plan';
29 use tests_common;
30
31 # Configuration variables defined in tests_common
32 # Make sure those are updated/set correctly..
33 # $api_base
34 # $api_key
35 #
36 # Further variables defined in tests_common:
37 # $invalid_key
38 # $test_username
39 # $test_password
40 # $invalid_username
41
42 my ($data, $temp, $test_domain, $test_remote_domain );
43
44 isa_ok( $g_ua, 'LWP::UserAgent', '$g_ua');
45 isa_ok( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
46
47 login_apikey();
48
49 $data = exec_apinode("domain/list", undef);
50 is( $data->{'response'}, 'ok', 'domain/list result');
51 ok($data->{'list'}, 'domain/list array');
52
53 # NOW: Set the $test_domain to something useful (i.e. the first reported domain)
54 $test_domain = $data->{'list'}[0];
55 ok($test_domain, 'test_domain set.');
56 undef $data;
57
58 $data = exec_apinode("domain/get_servers", { "domain" => $test_domain });
59 is( $data->{'response'}, 'ok', 'domain/get_servers result');
60 ok($data->{'servers'}->{'domain'}, 'domain/get_servers - domain');
61 ok($data->{'servers'}->{'registrar'}, 'domain/get_servers - registrar');
62 ok($data->{'servers'}->{'r_port'}, 'domain/get_servers - r_port');
63 ok($data->{'servers'}->{'proxy'}, 'domain/get_servers - proxy');
64 ok($data->{'servers'}->{'p_port'}, 'domain/get_servers - p_port');
65 ok($data->{'servers'}->{'prov_url'}, 'domain/get_servers - prov_url');
66 undef $data;
67
68 $data = exec_apinode("domain/set_servers", {
69 "domain" => $test_domain,
70 "registrar" => "registrar." . $test_domain,
71 "r_port" => 5060,
72 "proxy" => "proxy." . $test_domain,
73 "p_port" => 5060,
74 "prov_url" => "http://phone." . $test_domain . "/hermes/prov/",
75 } );
76
77 is( $data->{'response'}, 'ok', 'domain/set_servers result');
78 ok($data->{'servers'}->{'domain'}, 'domain/set_servers - domain');
79 ok($data->{'servers'}->{'registrar'}, 'domain/set_servers - registrar');
80 ok($data->{'servers'}->{'r_port'}, 'domain/set_servers - r_port');
81 ok($data->{'servers'}->{'proxy'}, 'domain/set_servers - proxy');
82 ok($data->{'servers'}->{'p_port'}, 'domain/set_servers - p_port');
83 ok($data->{'servers'}->{'prov_url'}, 'domain/set_servers - prov_url');
84 undef $data;
85
86 logout();
87