Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8fb8704993
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (28 sloc) 1.196 kb
# Test the basic auth code path
use v6;
use Test;
use LWP::Simple;
my $basic-auth-url = '';
my @url = LWP::Simple.parse_url($basic-auth-url);
is(@url[0], 'https', 'Scheme parsed correctly');
is(@url[1], '', 'Hostname contains basic auth info');
is(@url[2], 443, 'HTTPS demands port 443');
is(@url[3], '/p6-lwp-simple/basic-auth/', 'Path extracted correctly');
is(@url[4]<user>, 'ron', 'Basic auth info extracted correctly: user');
is(@url[4]<password>, 'Camelia', 'Basic auth info extracted correctly: pass');
is(@url[4]<host>, '', 'Basic auth info extracted correctly: hostname');
# my ($auth_u, $auth_p, $auth_h)= LWP::Simple.has_basic_auth(@url[1]);
# ok($auth_h eq '' && $auth_u eq 'ron' && $auth_p eq 'Camelia',
# 'test deprecated has_basic_auth method');
# Encode test
LWP::Simple.base64encode('someuser', 'somepass'),
'Base64 encoding works'
$basic-auth-url ~~ s/^https/http/;
my $html = LWP::Simple.get($basic-auth-url);
ok($html.match('protected'), 'Got protected url');
Jump to Line
Something went wrong with that request. Please try again.