]> git.defcon.no Git - hermes/blobdiff - api/t/user.t
Ooops on last commit. forgot to include a majority of the changes...
[hermes] / api / t / user.t
index 6548f26f7f8a4159fd497c4aad4dd1751ec322a4..81d908dafbe58cc59b256e2ab13b323cad290bd8 100644 (file)
@@ -15,9 +15,10 @@ my $api_pass  = "Very5ecr3t";
 my $test_username = "testuser-" . int(rand(255));
 my $test_aliasname = "testalias-" . int(rand(255));
 
-my $test_domain = "example.com"; #TODO: Must fetch this from API
+my $test_domain = undef;
+
+my $test_remote_domain = undef;
 
-my $test_remote_domain = "external.example.com";
 
 # plan tests => 2;
 my ($g_ua, $response, $data, $temp);
@@ -39,6 +40,23 @@ TODO: {
        undef $response; undef $data;
 }
 
+# First: fetch a supported domain from the API...
+$response = $g_ua->get( $api_base . "domain/list");
+isa_ok( $response, 'HTTP::Response',   'domain/list $response');
+ok ($response->is_success,             'domain/list is_success');
+$data = decode_json( $response->content);
+ok($data,                              'domain/list JSON decode');
+is( $data->{'response'}, 'ok',                 'domain/list result');
+ok($data->{'list'},                    'domain/list array');
+
+# NOW: Set the $test_domain to something useful (i.e. the first reported domain)
+$test_domain = $data->{'list'}[0];
+$test_remote_domain = "external." . $test_domain;
+
+ok($test_domain,                       'test_domain set.');
+ok($test_remote_domain,                        'test_remote_domain set.');
+undef $response; undef $data;
+
 $response = $g_ua->get( $api_base . "user/list");
 isa_ok( $response, 'HTTP::Response',   'user/list $response');
 ok ($response->is_success,             'user/list is_success');