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/";
29 #my $store_module = 'DBMDeep';
30 my $store_module = 'YAML';
32 ok( my $server = CWMP::Server->new({
36 module => $store_module,
41 isa_ok( $server, 'CWMP::Server' );
48 } elsif (defined($pid)) {
56 sleep 1; # so server can start
58 ok( my $s = Net::HTTP->new(Host => "localhost:$port"), 'client' );
61 ok( $s->write_request(
63 'Transfer-Encoding' => 'chunked',
65 'Content-Type' => 'text/xml',
68 foreach my $chunk (qq{
70 <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">
72 <cwmp:ID soapenv:mustUnderstand="1">1_THOM_TR69_ID</cwmp:ID>
77 <Manufacturer>THOMSON</Manufacturer>
79 <ProductClass>SpeedTouch 780</ProductClass>
80 <SerialNumber>CP0644JTHJ4</SerialNumber>
82 <Event soap:arrayType="cwmp:EventStruct[03]">
84 <EventCode>0 BOOTSTRAP</EventCode>
85 <CommandKey></CommandKey>
88 <Event},qq{Code>1 BOOT</EventCode>
89 <CommandKey></CommandKey>
92 <EventCode>4 VALUE CHANGE</EventCode>
93 <CommandKey></CommandKey>
96 <MaxEnvelopes>2</MaxEnvelopes>
97 <CurrentTime>1970-01-01T00:04:33Z</CurrentTime>
98 <RetryCount>01</RetryCount>},qq{
99 <ParameterList soap:arrayType="cwmp:ParameterValueStruct[12]">
100 <ParameterValueStruct>
101 <Name>InternetGatewayDevice.DeviceSummary</Name>
102 <Value xsi:type="xsd:string">InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)</Value>
103 </ParameterValueStruct>
104 <ParameterValueStruct>
106 InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
107 <Value xsi:type="xsd:string">1.1</Value>
108 </ParameterValueStruct>
109 <ParameterValueStruct>
110 <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
111 <Value xsi:type="xsd:string">BANT-R</Value>
112 </ParameterValueStruct>
113 <ParameterValueStruct>
114 <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
115 <Value xsi:type="xsd:string">6.2.15.5</Value>
116 </ParameterValueStruct>
117 <ParameterValueStruct>
118 <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
119 <Value xsi:type="xsd:string"></Value>
120 </ParameterValueStruct>
121 <ParameterValueStruct>
122 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name</Name>
123 <Value xsi:type="xsd:string">Routed PPPoE on 0/35 and 8/35</Value>
124 </ParameterValueStruct>
125 <ParameterValueStruct>
126 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version</Name>
127 <Value xsi:type="xsd:string"></Value>
128 </ParameterValueStruct>
129 <ParameterValueStruct>
130 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date</Name>
131 <Value xsi:type="xsd:dateTime">0000-00-00T00:00:00</Value>
132 </ParameterValueStruct>
133 <ParameterValueStruct>
134 <Name>InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description</Name>
135 <Value xsi:type="xsd:string">Factory Defaults</Value>
136 </ParameterValueStruct>
137 <ParameterValueStruct>
138 <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
139 <Value}, qq{ xsi:type="xsd:string">http://192.168.1.254:51005/</Value>
140 </ParameterValueStruct>
141 <ParameterValueStruct>
142 <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
143 <Value xsi:type="xsd:string"></Value>
144 </ParameterValueStruct>
145 <ParameterValueStruct>
146 <Name>.ExternalIPAddress</Name>
147 <Value xsi:type="xsd:string">192.168.1.254</Value>
148 </ParameterValueStruct>
154 ok( $s->write_chunk( $chunk ), "chunk " . length($chunk) . " bytes" );
156 ok( $s->write_chunk_eof, 'write_chunk_eof' );
160 ok( my $store = CWMP::Store->new({ module => $store_module, path => $store_path, debug => $debug }), 'another store' );
163 CurrentTime => "1970-01-01T00:04:33Z",
165 Manufacturer => "THOMSON",
167 ProductClass => "SpeedTouch 780",
168 SerialNumber => "CP0644JTHJ4",
170 EventStruct => ["0 BOOTSTRAP", "1 BOOT", "4 VALUE CHANGE"],
171 ID => "1_THOM_TR69_ID",
173 NoMoreRequests => undef,
175 "\nInternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1",
176 ".ExternalIPAddress" => "192.168.1.254",
177 "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-R",
178 "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef,
179 "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5",
180 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00",
181 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults",
182 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35",
183 "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef,
184 "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)",
185 "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/",
186 "InternetGatewayDevice.ManagementServer.ParameterKey" => undef,
189 _dispatch => "InformResponse",
192 is_deeply( $store->get_state( ID => '1_THOM_TR69_ID' ), $state, 'new store->get_state' );
194 ok( kill(9,$pid), 'kill ' . $pid );
196 ok( waitpid($pid,0), 'waitpid' );