10 use Util qw(:server :test :ua);
12 my $server = start_server('t/app.psgi');
14 plan tests => scalar user_agents;
16 test_all_user_agents {
20 my $any_ua = HTTP::AnyUA->new($ua, response_is_future => 1);
23 my $pass = 'opensesame';
24 my $auth = 'Ym9iOm9wZW5zZXNhbWU=';
25 my $path = '/get-document';
26 my $url = $server->url . $path;
27 $url =~ s!^(https?://)!${1}${user}:${pass}\@!;
28 my $future = $any_ua->get($url);
30 $future->on_ready(sub {
32 my $resp = $self->is_done ? $self->get : $self->failure;
33 my $env = $server->read_env;
35 note explain 'RESPONSE: ', $resp;
36 note explain 'ENV: ', $env;
39 skip 'unexpected env', 4 if ref($env) ne 'HASH';
40 is($env->{REQUEST_METHOD}, 'GET', 'correct method sent');
41 is($env->{REQUEST_URI}, $path, 'correct url sent');
42 is($env->{content}, '', 'no body sent');
43 is($env->{HTTP_AUTHORIZATION}, "Basic $auth", 'correct authorization sent');
46 is_response_content($resp, 'this is a document');
47 is_response_reason($resp, 'OK');
48 is_response_status($resp, 200);
49 is_response_success($resp, 1);
51 local $TODO = 'some user agents strip the auth from the URL';
52 # Mojo::UserAgent strips the auth from the URL
53 is_response_url($resp, $url);
55 is_response_header($resp, 'content-type', 'text/plain');
56 is_response_header($resp, 'content-length', 18);
57 response_protocol_ok($resp);