5 my $debug = shift @ARGV;
7 use Test::More tests => 19;
8 use Data::Dump qw/dump/;
14 use_ok('CWMP::Server');
15 use_ok('CWMP::Store');
21 $SIG{ALRM} = sub { die; };
25 ok(my $abs_path = abs_path($0), "abs_path");
26 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
28 my $store_path = "$abs_path/var/state.db";
29 unlink $store_path if -e $store_path;
31 ok( my $server = CWMP::Server->new({
34 store_path => $store_path,
36 isa_ok( $server, 'CWMP::Server' );
43 } elsif (defined($pid)) {
51 sleep 1; # so server can start
53 ok( my $s = Net::HTTP->new(Host => "localhost:$port"), 'client' );
56 ok( $s->write_request(
58 'Transfer-Encoding' => 'chunked',
60 'Content-Type' => 'text/xml',
63 foreach my $chunk (qq{
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">
67 <cwmp:ID soapenv:mustUnderstand="1">1_THOM_TR69_ID</cwmp:ID>
72 <Manufacturer>THOMSON</Manufacturer>
74 <ProductClass>SpeedTouch 780</ProductClass>
75 <SerialNumber>CP0644JTHJ4</SerialNumber>
77 <Event soap:arrayType="cwmp:EventStruct[03]">
79 <EventCode>0 BOOTSTRAP</EventCode>
80 <CommandKey></CommandKey>
83 <Event},qq{Code>1 BOOT</EventCode>
84 <CommandKey></CommandKey>
87 <EventCode>4 VALUE CHANGE</EventCode>
88 <CommandKey></CommandKey>
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>
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>
149 ok( $s->write_chunk( $chunk ), "chunk " . length($chunk) . " bytes" );
151 ok( $s->write_chunk_eof, 'write_chunk_eof' );
155 ok( my $store = CWMP::Store->new({ path => $store_path, debug => $debug }), 'another store' );
158 CurrentTime => "1970-01-01T00:04:33Z",
160 Manufacturer => "THOMSON",
162 ProductClass => "SpeedTouch 780",
163 SerialNumber => "CP0644JTHJ4",
165 EventStruct => ["0 BOOTSTRAP", "1 BOOT", "4 VALUE CHANGE"],
166 ID => "1_THOM_TR69_ID",
168 NoMoreRequests => undef,
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,
184 _dispatch => "InformResponse",
187 is_deeply( $store->state( ID => '1_THOM_TR69_ID' ), $state, 'new store->state' );
189 ok( kill(9,$pid), 'kill ' . $pid );
191 ok( waitpid($pid,0), 'waitpid' );