5 my $debug = shift @ARGV;
7 use Test::More tests => 20;
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/";
29 #my $store_module = 'DBMDeep';
30 my $store_module = 'YAML';
32 ok( my $server = CWMP::Server->new({
37 module => $store_module,
44 isa_ok( $server, 'CWMP::Server' );
51 } elsif (defined($pid)) {
59 sleep 1; # so server can start
61 ok( my $s = Net::HTTP->new(Host => "localhost:$port"), 'client' );
64 ok( $s->write_request(
66 'Transfer-Encoding' => 'chunked',
68 'Content-Type' => 'text/xml',
71 foreach my $chunk (qq{
73 <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">
75 <cwmp:ID soapenv:mustUnderstand="1">1_THOM_TR69_ID</cwmp:ID>
80 <Manufacturer>THOMSON</Manufacturer>
82 <ProductClass>SpeedTouch 780</ProductClass>
83 <SerialNumber>CP0644JTHJ4</SerialNumber>
85 <Event soap:arrayType="cwmp:EventStruct[03]">
87 <EventCode>0 BOOTSTRAP</EventCode>
88 <CommandKey></CommandKey>
91 <Event},qq{Code>1 BOOT</EventCode>
92 <CommandKey></CommandKey>
95 <EventCode>4 VALUE CHANGE</EventCode>
96 <CommandKey></CommandKey>
99 <MaxEnvelopes>2</MaxEnvelopes>
100 <CurrentTime>1970-01-01T00:04:33Z</CurrentTime>
101 <RetryCount>01</RetryCount>},qq{
102 <ParameterList soap:arrayType="cwmp:ParameterValueStruct[12]">
103 <ParameterValueStruct>
104 <Name>InternetGatewayDevice.DeviceSummary</Name>
105 <Value xsi:type="xsd:string">InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)</Value>
106 </ParameterValueStruct>
107 <ParameterValueStruct>
109 InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
110 <Value xsi:type="xsd:string">1.1</Value>
111 </ParameterValueStruct>
112 <ParameterValueStruct>
113 <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
114 <Value xsi:type="xsd:string">BANT-R</Value>
115 </ParameterValueStruct>
116 <ParameterValueStruct>
117 <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
118 <Value xsi:type="xsd:string">6.2.15.5</Value>
119 </ParameterValueStruct>
120 <ParameterValueStruct>
121 <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
122 <Value xsi:type="xsd:string"></Value>
123 </ParameterValueStruct>
124 <ParameterValueStruct>
125 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name</Name>
126 <Value xsi:type="xsd:string">Routed PPPoE on 0/35 and 8/35</Value>
127 </ParameterValueStruct>
128 <ParameterValueStruct>
129 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version</Name>
130 <Value xsi:type="xsd:string"></Value>
131 </ParameterValueStruct>
132 <ParameterValueStruct>
133 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date</Name>
134 <Value xsi:type="xsd:dateTime">0000-00-00T00:00:00</Value>
135 </ParameterValueStruct>
136 <ParameterValueStruct>
137 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description</Name>
138 <Value xsi:type="xsd:string">Factory Defaults</Value>
139 </ParameterValueStruct>
140 <ParameterValueStruct>
141 <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
142 <Value}, qq{ xsi:type="xsd:string">http://192.168.1.254:51005/</Value>
143 </ParameterValueStruct>
144 <ParameterValueStruct>
145 <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
146 <Value xsi:type="xsd:string"></Value>
147 </ParameterValueStruct>
148 <ParameterValueStruct>
149 <Name>.ExternalIPAddress</Name>
150 <Value xsi:type="xsd:string">192.168.1.254</Value>
151 </ParameterValueStruct>
157 ok( $s->write_chunk( $chunk ), "chunk " . length($chunk) . " bytes" );
159 ok( $s->write_chunk_eof, 'write_chunk_eof' );
163 ok( my $store = CWMP::Store->new({ module => $store_module, path => $store_path, debug => $debug }), 'another store' );
166 CurrentTime => "1970-01-01T00:04:33Z",
168 Manufacturer => "THOMSON",
170 ProductClass => "SpeedTouch 780",
171 SerialNumber => "CP0644JTHJ4",
173 EventStruct => ["0 BOOTSTRAP", "1 BOOT", "4 VALUE CHANGE"],
174 ID => "1_THOM_TR69_ID",
176 # NoMoreRequests => undef,
178 "\nInternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1",
179 ".ExternalIPAddress" => "192.168.1.254",
180 "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-R",
181 "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef,
182 "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5",
183 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00",
184 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults",
185 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35",
186 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef,
187 "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)",
188 "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/",
189 "InternetGatewayDevice.ManagementServer.ParameterKey" => undef,
192 _dispatch => "InformResponse",
195 ok( my $store_state = $store->current_store->get_state( 'CP0644JTHJ4' ), 'get_state' );
197 is_deeply( $store_state, $state, 'store->current_store->get_state' );
199 diag "shutdown server";
201 ok( kill(9,$pid), 'kill ' . $pid );
203 ok( waitpid($pid,0), 'waitpid' );