/usr/share/perl5/Plack/Test/ExternalServer.pm is in libplack-test-externalserver-perl 0.02-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | use strict;
use warnings;
package Plack::Test::ExternalServer; # git description: 0.01-3-g19ad453
# ABSTRACT: Run HTTP tests on external live servers
our $VERSION = '0.02';
use URI;
use Carp ();
use LWP::UserAgent;
#pod =head1 SYNOPSIS
#pod
#pod $ PLACK_TEST_IMPL=Plack::Test::ExternalServer \
#pod PLACK_TEST_EXTERNALSERVER_URI=http://myhost.example/myapp/ \
#pod perl my_plack_test.t
#pod
#pod =head1 DESCRIPTION
#pod
#pod This module allows your to run your Plack::Test tests against an external
#pod server instead of just against a local application through either mocked HTTP
#pod or a locally spawned server.
#pod
#pod See L<Plack::Test> on how to write tests that can use this module.
#pod
#pod =head1 ENVIRONMENT VARIABLES
#pod
#pod =over 4
#pod
#pod =item PLACK_TEST_EXTERNALSERVER_URI
#pod
#pod The value of this variable will be used as the base uri for requests to the
#pod external server.
#pod
#pod =back
#pod
#pod =head1 SEE ALSO
#pod
#pod L<Plack::Test>
#pod
#pod L<Plack::Test::Server>
#pod
#pod L<Plack::Test::MockHTTP>
#pod
#pod =begin Pod::Coverage
#pod
#pod test_psgi
#pod
#pod =end Pod::Coverage
#pod
#pod =cut
sub test_psgi {
my %args = @_;
my $client = delete $args{client} or Carp::croak 'client test code needed';
my $ua = delete $args{ua} || LWP::UserAgent->new;
my $base = $ENV{PLACK_TEST_EXTERNALSERVER_URI} || delete $args{uri};
$base = URI->new($base) if $base;
$client->(sub {
my ($req) = shift->clone;
if ($base) {
my $uri = $req->uri->clone;
$uri->scheme($base->scheme);
$uri->host($base->host);
$uri->port($base->port);
$uri->path($base->path . $uri->path);
$req->uri($uri);
}
return $ua->request($req);
});
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Plack::Test::ExternalServer - Run HTTP tests on external live servers
=head1 VERSION
version 0.02
=head1 SYNOPSIS
$ PLACK_TEST_IMPL=Plack::Test::ExternalServer \
PLACK_TEST_EXTERNALSERVER_URI=http://myhost.example/myapp/ \
perl my_plack_test.t
=head1 DESCRIPTION
This module allows your to run your Plack::Test tests against an external
server instead of just against a local application through either mocked HTTP
or a locally spawned server.
See L<Plack::Test> on how to write tests that can use this module.
=head1 ENVIRONMENT VARIABLES
=over 4
=item PLACK_TEST_EXTERNALSERVER_URI
The value of this variable will be used as the base uri for requests to the
external server.
=back
=head1 SEE ALSO
L<Plack::Test>
L<Plack::Test::Server>
L<Plack::Test::MockHTTP>
=for Pod::Coverage test_psgi
=head1 AUTHOR
Florian Ragwitz <rafl@debian.org>
=head1 CONTRIBUTOR
=for stopwords Karen Etheridge
Karen Etheridge <ether@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|