### ----------------------------------------------------
### -- HTTP::UserAgent
### -- Licenses: MIT
### -- Authors: Filip Sergot
### -- File: t/085-auth.rakutest
### ----------------------------------------------------
use Test;
use HTTP::UserAgent;

plan 7;

my $ua = HTTP::UserAgent.new;

lives-ok { $ua.auth('test', 'TEST' ) }, "set credentials";

is $ua.auth_login, 'test', "login got set okay";
is $ua.auth_password, 'TEST', "password got set okay";

my $res;

if %*ENV<NETWORK_TESTING>:exists {
   lives-ok { $res = $ua.get('http://httpbin.org/basic-auth/xxx/XXX') }, "get site that requires auth (bad credentials)";
   is $res.code, 401, "and it's a 401";

   lives-ok { $res = $ua.get('http://httpbin.org/basic-auth/test/TEST') }, "get site that requires auth (good credentials)";
   is $res.code, 200, "and it's a 200";
}
else {
   skip("NETWORK_TESTING is not set", 4);
}

# vim: expandtab shiftwidth=4


