/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (hide annotations)
Tue Jun 19 18:37:24 2007 UTC (17 years ago) by dpavlin
File MIME type: application/x-troff
File size: 4235 byte(s)
check if socket is connected, use sock->send 
1 dpavlin 41 #!/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     ok( my $s = Net::HTTP->new(Host => "localhost:$port"), 'client' );
40 dpavlin 42 $s->keep_alive( 1 );
41 dpavlin 41
42     ok( $s->write_request(
43     POST => '/',
44     'Transfer-Encoding' => 'chunked',
45     'SOAPAction' => '',
46     'Content-Type' => 'text/xml',
47     ), 'write_request' );
48    
49     foreach my $chunk (qq{
50    
51     <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">
52     <soapenv:Header>
53     <cwmp:ID soapenv:mustUnderstand="1">1_THOM_TR69_ID</cwmp:ID>
54     </soapenv:Header>
55     <soapenv:Body>
56     <cwmp:Inform>
57     <DeviceId>
58     <Manufacturer>THOMSON</Manufacturer>
59     <OUI>00147F</OUI>
60     <ProductClass>SpeedTouch 780</ProductClass>
61     <SerialNumber>CP0644JTHJ4</SerialNumber>
62     </DeviceId>
63     <Event soap:arrayType="cwmp:EventStruct[03]">
64     <EventStruct>
65     <EventCode>0 BOOTSTRAP</EventCode>
66     <CommandKey></CommandKey>
67     </EventStruct>
68     <EventStruct>
69     <Event},qq{Code>1 BOOT</EventCode>
70     <CommandKey></CommandKey>
71     </EventStruct>
72     <EventStruct>
73     <EventCode>4 VALUE CHANGE</EventCode>
74     <CommandKey></CommandKey>
75     </EventStruct>
76     </Event>
77     <MaxEnvelopes>2</MaxEnvelopes>
78     <CurrentTime>1970-01-01T00:04:33Z</CurrentTime>
79     <RetryCount>01</RetryCount>},qq{
80     <ParameterList soap:arrayType="cwmp:ParameterValueStruct[12]">
81     <ParameterValueStruct>
82     <Name>InternetGatewayDevice.DeviceSummary</Name>
83     <Value xsi:type="xsd:string">InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)</Value>
84     </ParameterValueStruct>
85     <ParameterValueStruct>
86     <Name>}, qq{
87     InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
88     <Value xsi:type="xsd:string">1.1</Value>
89     </ParameterValueStruct>
90     <ParameterValueStruct>
91     <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
92     <Value xsi:type="xsd:string">BANT-R</Value>
93     </ParameterValueStruct>
94     <ParameterValueStruct>
95     <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
96     <Value xsi:type="xsd:string">6.2.15.5</Value>
97     </ParameterValueStruct>
98     <ParameterValueStruct>
99     <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
100     <Value xsi:type="xsd:string"></Value>
101     </ParameterValueStruct>
102     <ParameterValueStruct>
103     <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name</Name>
104     <Value xsi:type="xsd:string">Routed PPPoE on 0/35 and 8/35</Value>
105     </ParameterValueStruct>
106     <ParameterValueStruct>
107     <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version</Name>
108     <Value xsi:type="xsd:string"></Value>
109     </ParameterValueStruct>
110     <ParameterValueStruct>
111     <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date</Name>
112     <Value xsi:type="xsd:dateTime">0000-00-00T00:00:00</Value>
113     </ParameterValueStruct>
114     <ParameterValueStruct>
115     <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description</Name>
116     <Value xsi:type="xsd:string">Factory Defaults</Value>
117     </ParameterValueStruct>
118     <ParameterValueStruct>
119     <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
120     <Value}, qq{ xsi:type="xsd:string">http://192.168.1.254:51005/</Value>
121     </ParameterValueStruct>
122     <ParameterValueStruct>
123     <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
124     <Value xsi:type="xsd:string"></Value>
125     </ParameterValueStruct>
126     <ParameterValueStruct>
127     <Name>.ExternalIPAddress</Name>
128     <Value xsi:type="xsd:string">192.168.1.254</Value>
129     </ParameterValueStruct>
130     </ParameterList>
131     </cwmp:Inform>
132     </soapenv:Body>
133     </soapenv:Envelope>
134     } ) {
135     ok( $s->write_chunk( $chunk ), "chunk " . length($chunk) . " bytes" );
136     }
137     ok( $s->write_chunk_eof, 'write_chunk_eof' );
138    
139     ok( kill(1,$pid), 'kill ' . $pid );
140    
141     ok( waitpid($pid,0), 'waitpid' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26