X-Git-Url: https://git.defcon.no/?a=blobdiff_plain;f=api%2Ft%2Fuser.t;h=81d908dafbe58cc59b256e2ab13b323cad290bd8;hb=c2f99e5e48ac8d3be1f3140b696bd307a4adb9d0;hp=6548f26f7f8a4159fd497c4aad4dd1751ec322a4;hpb=be41f0805a67c31020a0910511d15f4c70603f59;p=hermes diff --git a/api/t/user.t b/api/t/user.t index 6548f26..81d908d 100644 --- a/api/t/user.t +++ b/api/t/user.t @@ -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');