LJ-Simple
view release on metacpan or search on metacpan
results => {},
) == 1) { ok(1) } else { ok(0) }
$LJ::Simple::TestStopQuickPost = 0;
#goto LOGIN;
## Test object creation via new - should fail
my $lj = new LJ::Simple();
if (!defined $lj) { ok(1) } else { ok(0) }
## Test object creation via login - should fail
$lj = LJ::Simple->login();
if (!defined $lj) { ok(1) } else { ok(0) }
if (1) {
# $LJ::Simple::debug=1;
# $LJ::Simple::protocol=1;
}
## Test object creation by going to a site not running LJ
$lj = new LJ::Simple ({
user => "test",
pass => "test",
site => "httpd.apache.org",
});
if (!defined $lj) {
ok($LJ::Simple::error,'/HTTP request failed/');
} else {
ok(0);
}
## Test object creation with what is (hopefully) an invalid username
$lj = new LJ::Simple ({
user => "testmmeekmooo",
pass => "test",
site => undef,
});
if (!defined $lj) {
ok($LJ::Simple::error,'/LJ request failed: Invalid username/');
} else {
ok(0);
}
## Test object creation with a valid user, but invalid password
$lj = new LJ::Simple ({
user => $user,
pass => "testy",
site => undef,
});
if (!defined $lj) {
ok($LJ::Simple::error,'/LJ request failed: Invalid password/');
} else {
ok(0);
}
##
## Some quick checks of the HTTP proxy support via environment variables
##
my %CopyEnv=();
my $ProxyTest="example.com";
my @ProxyVars=(qw( http_proxy HTTP_PROXY ));
map { (exists $ENV{$_}) && ($CopyEnv{$_}=$ENV{$_}) } (@ProxyVars);
map { delete $ENV{$_} } (@ProxyVars);
# proxy overrides EnvVar
$ENV{http_proxy}="http://$ProxyTest/";
$lj = new LJ::Simple({
user => $user,
pass => $pass,
fast => 1, # Don't want to actually login
proxy => undef,
});
if (defined $lj) {
if (defined $lj->{proxy}) { ok(0) } else { ok(1) }
} else {
ok(0);
}
# http_proxy, default port
$ENV{http_proxy}="http://$ProxyTest/";
$lj = new LJ::Simple({
user => $user,
pass => $pass,
fast => 1, # Don't want to actually login
});
if (defined $lj) {
if (ref($lj->{proxy}) ne "HASH") { ok(0)
} else {
if ($lj->{proxy}->{host} ne $ProxyTest) { ok(0)
} else {
if ($lj->{proxy}->{port} ne "3128") { ok(0)
} else {
ok(1);
}
}
}
} else {
ok(0);
}
# http_proxy, non-standard port
$ENV{http_proxy}="http://$ProxyTest:80/";
$lj = new LJ::Simple({
user => $user,
pass => $pass,
fast => 1, # Don't want to actually login
});
if (defined $lj) {
if (ref($lj->{proxy}) ne "HASH") { ok(0)
} else {
if ($lj->{proxy}->{host} ne $ProxyTest) { ok(0)
} else {
if ($lj->{proxy}->{port} ne "80") { ok(0)
} else {
ok(1);
}
}
}
} else {
ok(0);
}
( run in 1.640 second using v1.01-cache-2.11-cpan-71847e10f99 )