4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 5; |
use Test::More tests => 7; |
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
use blib; |
use blib; |
10 |
|
|
18 |
ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' ); |
ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' ); |
19 |
isa_ok( $response, 'CWMP::Response' ); |
isa_ok( $response, 'CWMP::Response' ); |
20 |
|
|
21 |
ok( my $inform = $response->Inform({ ID => 42 }), 'Inform' ); |
sub is_like { |
22 |
|
my ( $command, $template_xml ) = @_; |
23 |
|
|
24 |
like( $inform, qr{\Q<soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
ok( my $xml = $response->$command({ ID => 42 }), $command ); |
25 |
|
diag $xml if $debug; |
26 |
|
chomp( $xml ); |
27 |
|
chomp( $template_xml ); |
28 |
|
like( $xml, qr{^\Q$template_xml\E$}, $command . ' xml' ); |
29 |
|
} |
30 |
|
|
31 |
|
is_like( 'Inform', <<__SOAP__ |
32 |
|
<soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
33 |
<soap:Header> |
<soap:Header> |
34 |
<cwmp:ID mustUnderstand="1">42</cwmp:ID> |
<cwmp:ID mustUnderstand="1">42</cwmp:ID> |
35 |
</soap:Header> |
</soap:Header> |
38 |
<cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes> |
<cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes> |
39 |
</cwmp:InformResponse> |
</cwmp:InformResponse> |
40 |
</soap:Body> |
</soap:Body> |
41 |
</soap:Envelope>\E}, 'xml'); |
</soap:Envelope> |
42 |
|
__SOAP__ |
43 |
|
); |
44 |
|
|
45 |
diag $inform if $debug; |
is_like( 'GetRPCMethods', <<__SOAP__ |
46 |
|
<soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
47 |
|
<soap:Header> |
48 |
|
<cwmp:ID mustUnderstand="1">42</cwmp:ID> |
49 |
|
</soap:Header> |
50 |
|
<soap:Body> |
51 |
|
<GetRPCMethods /> |
52 |
|
</soap:Body> |
53 |
|
</soap:Envelope> |
54 |
|
__SOAP__ |
55 |
|
); |