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);
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');