/[cwmp]/google/trunk/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/trunk/t/30-server.t

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26