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
|
package MyTypemap;
sub get_typemap { return {} };
package HandlerClass;
sub bar {
return "Verdammte Axt";
}
package main;
use Test::More;
eval "require IO::Scalar"
or plan skip_all => 'IO::Scalar required for testing...';
plan tests => 12;
use_ok(SOAP::WSDL::Server);
use_ok(SOAP::WSDL::Server::CGI);
my $server = SOAP::WSDL::Server::CGI->new({
class_resolver => 'MyTypemap',
});
$server->set_action_map_ref({
'testaction' => 'testmethod',
});
{
no warnings qw(once);
*IO::Scalar::BINMODE = sub {};
}
my $output = q{};
my $fh = IO::Scalar->new(\$output);
my $stdout = *STDOUT;
my $stdin = *STDIN;
# don't try to print() anything from here on - it gets caught in $output,
#and does not make it to STDOUT...
my $path = $ENV{PATH};
*STDOUT = $fh;
{
local %ENV;
$ENV{PATH} = $path;
$server->handle();
like $output, qr{ \A Status: \s 411 \s Length \s Required}x;
$output = q{};
$ENV{'CONTENT_LENGTH'} = '0e0';
$server->handle();
like $output, qr{ Error \s deserializing }xsm;
$output = q{};
$server->set_action_map_ref({
'foo' => 'bar',
});
$server->set_dispatch_to( 'HandlerClass' );
$server->handle();
like $output, qr{no \s element \s found}xms;
$output = q{};
$ENV{REQUEST_METHOD} = 'POST';
$ENV{HTTP_SOAPACTION} = 'test';
$server->handle();
like $output, qr{no \s element \s found}xms;
$output = q{};
delete $ENV{HTTP_SOAPACTION};
$ENV{EXPECT} = 'Foo';
$ENV{HTTP_SOAPAction} = 'foo';
$server->handle();
like $output, qr{no \s element \s found}xms;
$output = q{};
$ENV{EXPECT} = '100-Continue';
$ENV{HTTP_SOAPAction} = 'foo';
$server->handle();
like $output, qr{100 \s Continue}xms;
$output = q{};
delete $ENV{EXPECT};
my $input = 'Foobar';
my $ih = IO::Scalar->new(\$input);
$ih->seek(0);
*STDIN = $ih;
$ENV{HTTP_SOAPAction} = 'bar';
$ENV{CONTENT_LENGTH} = 6;
$server->handle();
like $output, qr{ Error \s deserializing \s message}xms;
$output = q{};
$ih->seek(0);
$input = q{<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>};
$ENV{HTTP_SOAPAction} = 'bar';
$ENV{CONTENT_LENGTH} = length $input;
$server->handle();
like $output, qr{ Not \s found:}xms;
$output = q{};
$ih->seek(0);
$server->set_dispatch_to( 'HandlerClass' );
$server->set_action_map_ref({
'bar' => 'bar',
});
$input = q{<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>};
$ENV{HTTP_SOAPAction} = q{"bar"};
$ENV{CONTENT_LENGTH} = length $input;
$server->handle();
use Data::Dumper;
like $output, qr{ \A Status: \s 200 \s OK}xms;
$output = q{};
$ih->seek(0);
$server->set_dispatch_to( 'HandlerClass' );
$server->set_action_map_ref({
'bar' => 'bar',
});
$input = q{<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>};
$ENV{SERVER_SOFTWARE} ='IIS Foobar';
$ENV{HTTP_SOAPAction} = q{"bar"};
$ENV{CONTENT_LENGTH} = length $input;
$server->handle();
use Data::Dumper;
like $output, qr{ \A HTTP/1.0 \s 200 \s OK}xms;
$output = q{};
$ih->seek(0);
}
# restore handles
*STDOUT = $stdout;
*STDIN = $stdin;
|