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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26