/[cwmp]/google/t/30-server.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /google/t/30-server.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations)
Tue Jun 19 18:11:37 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 4236 byte(s)
added server tests (and fixed server in process ;-)
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 15;
8 use Data::Dump qw/dump/;
9 use blib;
10
11 BEGIN {
12 use_ok('Net::HTTP');
13 use_ok('CWMP::Server');
14 }
15
16 my $port = 4242;
17
18 eval {
19 $SIG{ALRM} = sub { die; };
20 alarm 30;
21 };
22
23 ok( my $server = CWMP::Server->new({ debug => $debug, port => $port }), 'new' );
24 isa_ok( $server, 'CWMP::Server' );
25
26 my $pid;
27
28 if ( $pid = fork ) {
29 ok( $pid, 'fork ');
30 diag "forked $pid";
31 } elsif (defined($pid)) {
32 # child
33 $server->run;
34 exit;
35 } else {
36 die "can't fork";
37 }
38
39
40 ok( my $s = Net::HTTP->new(Host => "localhost:$port"), 'client' );
41 #$s->keepalive( 1 );
42
43 ok( $s->write_request(
44 POST => '/',
45 'Transfer-Encoding' => 'chunked',
46 'SOAPAction' => '',
47 'Content-Type' => 'text/xml',
48 ), 'write_request' );
49
50 foreach my $chunk (qq{
51
52 <soapenv:Envelope soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
53 <soapenv:Header>
54 <cwmp:ID soapenv:mustUnderstand="1">1_THOM_TR69_ID</cwmp:ID>
55 </soapenv:Header>
56 <soapenv:Body>
57 <cwmp:Inform>
58 <DeviceId>
59 <Manufacturer>THOMSON</Manufacturer>
60 <OUI>00147F</OUI>
61 <ProductClass>SpeedTouch 780</ProductClass>
62 <SerialNumber>CP0644JTHJ4</SerialNumber>
63 </DeviceId>
64 <Event soap:arrayType="cwmp:EventStruct[03]">
65 <EventStruct>
66 <EventCode>0 BOOTSTRAP</EventCode>
67 <CommandKey></CommandKey>
68 </EventStruct>
69 <EventStruct>
70 <Event},qq{Code>1 BOOT</EventCode>
71 <CommandKey></CommandKey>
72 </EventStruct>
73 <EventStruct>
74 <EventCode>4 VALUE CHANGE</EventCode>
75 <CommandKey></CommandKey>
76 </EventStruct>
77 </Event>
78 <MaxEnvelopes>2</MaxEnvelopes>
79 <CurrentTime>1970-01-01T00:04:33Z</CurrentTime>
80 <RetryCount>01</RetryCount>},qq{
81 <ParameterList soap:arrayType="cwmp:ParameterValueStruct[12]">
82 <ParameterValueStruct>
83 <Name>InternetGatewayDevice.DeviceSummary</Name>
84 <Value xsi:type="xsd:string">InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)</Value>
85 </ParameterValueStruct>
86 <ParameterValueStruct>
87 <Name>}, qq{
88 InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
89 <Value xsi:type="xsd:string">1.1</Value>
90 </ParameterValueStruct>
91 <ParameterValueStruct>
92 <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
93 <Value xsi:type="xsd:string">BANT-R</Value>
94 </ParameterValueStruct>
95 <ParameterValueStruct>
96 <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
97 <Value xsi:type="xsd:string">6.2.15.5</Value>
98 </ParameterValueStruct>
99 <ParameterValueStruct>
100 <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
101 <Value xsi:type="xsd:string"></Value>
102 </ParameterValueStruct>
103 <ParameterValueStruct>
104 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name</Name>
105 <Value xsi:type="xsd:string">Routed PPPoE on 0/35 and 8/35</Value>
106 </ParameterValueStruct>
107 <ParameterValueStruct>
108 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version</Name>
109 <Value xsi:type="xsd:string"></Value>
110 </ParameterValueStruct>
111 <ParameterValueStruct>
112 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date</Name>
113 <Value xsi:type="xsd:dateTime">0000-00-00T00:00:00</Value>
114 </ParameterValueStruct>
115 <ParameterValueStruct>
116 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description</Name>
117 <Value xsi:type="xsd:string">Factory Defaults</Value>
118 </ParameterValueStruct>
119 <ParameterValueStruct>
120 <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
121 <Value}, qq{ xsi:type="xsd:string">http://192.168.1.254:51005/</Value>
122 </ParameterValueStruct>
123 <ParameterValueStruct>
124 <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
125 <Value xsi:type="xsd:string"></Value>
126 </ParameterValueStruct>
127 <ParameterValueStruct>
128 <Name>.ExternalIPAddress</Name>
129 <Value xsi:type="xsd:string">192.168.1.254</Value>
130 </ParameterValueStruct>
131 </ParameterList>
132 </cwmp:Inform>
133 </soapenv:Body>
134 </soapenv:Envelope>
135 } ) {
136 ok( $s->write_chunk( $chunk ), "chunk " . length($chunk) . " bytes" );
137 }
138 ok( $s->write_chunk_eof, 'write_chunk_eof' );
139
140 ok( kill(1,$pid), 'kill ' . $pid );
141
142 ok( waitpid($pid,0), 'waitpid' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26