63SCENARIO(
"sshDigger Configuration",
"[sshDigger]" )
66 #ifdef SSHDIGGER_TEST_DOXYGEN_REF
73 GIVEN(
"a config file with 1 tunnel" )
75 WHEN(
"the tunnel is fully specified and matches configName" )
77 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
78 {
"tunnel1",
"tunnel1",
"tunnel1" },
79 {
"remoteHost",
"localPort",
"remotePort" },
80 {
"exao2",
"80",
"81" } );
82 mx::app::appConfigurator config;
83 config.readConfig(
"/tmp/sshDigger_test.conf" );
86 dig.configName(
"tunnel1" );
88 rv = dig.loadConfigImpl( config );
91 REQUIRE( dig.remoteHost() ==
"exao2" );
92 REQUIRE( dig.localPort() == 80 );
93 REQUIRE( dig.remotePort() == 81 );
94 REQUIRE( dig.monitorPort() == 0 );
97 WHEN(
"the tunnel is fully specified and matches configName, includes monitorPort" )
99 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
100 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel1" },
101 {
"remoteHost",
"localPort",
"remotePort",
"monitorPort" },
102 {
"exao2",
"80",
"81",
"6000" } );
104 mx::app::appConfigurator config;
105 config.readConfig(
"/tmp/sshDigger_test.conf" );
108 dig.configName(
"tunnel1" );
110 rv = dig.loadConfigImpl( config );
113 REQUIRE( dig.remoteHost() ==
"exao2" );
114 REQUIRE( dig.localPort() == 80 );
115 REQUIRE( dig.remotePort() == 81 );
116 REQUIRE( dig.monitorPort() == 6000 );
119 WHEN(
"no unused sections" )
121 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf", {}, {}, {} );
123 mx::app::appConfigurator config;
124 config.readConfig(
"/tmp/sshDigger_test.conf" );
127 dig.configName(
"tunnel2" );
129 rv = dig.loadConfigImpl( config );
133 WHEN(
"the tunnel does not match configName" )
135 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
136 {
"tunnel1",
"tunnel1",
"tunnel1" },
137 {
"remoteHost",
"localPort",
"remotePort" },
138 {
"exao2",
"80",
"81" } );
140 mx::app::appConfigurator config;
141 config.readConfig(
"/tmp/sshDigger_test.conf" );
144 dig.configName(
"tunnel2" );
146 rv = dig.loadConfigImpl( config );
150 WHEN(
"no remote host" )
152 mx::app::writeConfigFile(
153 "/tmp/sshDigger_test.conf", {
"tunnel1",
"tunnel1" }, {
"localPort",
"remotePort" }, {
"80",
"81" } );
155 mx::app::appConfigurator config;
156 config.readConfig(
"/tmp/sshDigger_test.conf" );
159 dig.configName(
"tunnel1" );
161 rv = dig.loadConfigImpl( config );
165 WHEN(
"no local port" )
167 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
168 {
"tunnel1",
"tunnel1" },
169 {
"remoteHost",
"remotePort" },
172 mx::app::appConfigurator config;
173 config.readConfig(
"/tmp/sshDigger_test.conf" );
176 dig.configName(
"tunnel1" );
178 rv = dig.loadConfigImpl( config );
182 WHEN(
"no remote port" )
184 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
185 {
"tunnel1",
"tunnel1" },
186 {
"remoteHost",
"localPort" },
189 mx::app::appConfigurator config;
190 config.readConfig(
"/tmp/sshDigger_test.conf" );
193 dig.configName(
"tunnel1" );
195 rv = dig.loadConfigImpl( config );
199 GIVEN(
"a config file with 2 tunnels" )
201 WHEN(
"the tunnels are fully specified and match their configNames" )
203 mx::app::writeConfigFile(
204 "/tmp/sshDigger_test.conf",
205 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2",
"tunnel2" },
206 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
207 {
"exao2",
"80",
"81",
"exao3",
"85",
"86" } );
209 mx::app::appConfigurator config;
210 config.readConfig(
"/tmp/sshDigger_test.conf" );
215 dig.configName(
"tunnel1" );
217 rv = dig.loadConfigImpl( config );
219 REQUIRE( dig.remoteHost() ==
"exao2" );
220 REQUIRE( dig.localPort() == 80 );
221 REQUIRE( dig.remotePort() == 81 );
223 dig.configName(
"tunnel2" );
225 rv = dig.loadConfigImpl( config );
227 REQUIRE( dig.remoteHost() ==
"exao3" );
228 REQUIRE( dig.localPort() == 85 );
229 REQUIRE( dig.remotePort() == 86 );
232 WHEN(
"No tunnels match configName" )
234 mx::app::writeConfigFile(
235 "/tmp/sshDigger_test.conf",
236 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2",
"tunnel2" },
237 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
238 {
"exao2",
"80",
"81",
"exao3",
"85",
"86" } );
240 mx::app::appConfigurator config;
241 config.readConfig(
"/tmp/sshDigger_test.conf" );
244 dig.configName(
"tunnel3" );
246 rv = dig.loadConfigImpl( config );
250 WHEN(
"no remote host in first tunnel" )
252 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
253 {
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2",
"tunnel2" },
254 {
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
255 {
"80",
"81",
"exao3",
"85",
"86" } );
257 mx::app::appConfigurator config;
258 config.readConfig(
"/tmp/sshDigger_test.conf" );
261 dig.configName(
"tunnel1" );
263 rv = dig.loadConfigImpl( config );
266 dig.configName(
"tunnel2" );
268 rv = dig.loadConfigImpl( config );
270 REQUIRE( dig.remoteHost() ==
"exao3" );
271 REQUIRE( dig.localPort() == 85 );
272 REQUIRE( dig.remotePort() == 86 );
275 WHEN(
"no remote host in 2nd tunnel" )
277 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
278 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2" },
279 {
"remoteHost",
"localPort",
"remotePort",
"localPort",
"remotePort" },
280 {
"exao2",
"80",
"81",
"85",
"86" } );
282 mx::app::appConfigurator config;
283 config.readConfig(
"/tmp/sshDigger_test.conf" );
286 dig.configName(
"tunnel2" );
288 rv = dig.loadConfigImpl( config );
291 dig.configName(
"tunnel1" );
293 rv = dig.loadConfigImpl( config );
295 REQUIRE( dig.remoteHost() ==
"exao2" );
296 REQUIRE( dig.localPort() == 80 );
297 REQUIRE( dig.remotePort() == 81 );
300 WHEN(
"no local port in first tunnel" )
302 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
303 {
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2",
"tunnel2" },
304 {
"remoteHost",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
305 {
"exao2",
"81",
"exao3",
"85",
"86" } );
307 mx::app::appConfigurator config;
308 config.readConfig(
"/tmp/sshDigger_test.conf" );
311 dig.configName(
"tunnel1" );
313 rv = dig.loadConfigImpl( config );
316 dig.configName(
"tunnel2" );
318 rv = dig.loadConfigImpl( config );
320 REQUIRE( dig.remoteHost() ==
"exao3" );
321 REQUIRE( dig.localPort() == 85 );
322 REQUIRE( dig.remotePort() == 86 );
325 WHEN(
"no local port in second tunnel" )
327 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
328 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2" },
329 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"remotePort" },
330 {
"exao2",
"80",
"81",
"exao3",
"86" } );
332 mx::app::appConfigurator config;
333 config.readConfig(
"/tmp/sshDigger_test.conf" );
336 dig.configName(
"tunnel2" );
338 rv = dig.loadConfigImpl( config );
341 dig.configName(
"tunnel1" );
343 rv = dig.loadConfigImpl( config );
345 REQUIRE( dig.remoteHost() ==
"exao2" );
346 REQUIRE( dig.localPort() == 80 );
347 REQUIRE( dig.remotePort() == 81 );
350 WHEN(
"no remote port in first tunnel" )
352 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
353 {
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2",
"tunnel2" },
354 {
"remoteHost",
"localPort",
"remoteHost",
"localPort",
"remotePort" },
355 {
"exao2",
"80",
"exao3",
"85",
"86" } );
357 mx::app::appConfigurator config;
358 config.readConfig(
"/tmp/sshDigger_test.conf" );
361 dig.configName(
"tunnel1" );
363 rv = dig.loadConfigImpl( config );
366 dig.configName(
"tunnel2" );
368 rv = dig.loadConfigImpl( config );
370 REQUIRE( dig.remoteHost() ==
"exao3" );
371 REQUIRE( dig.localPort() == 85 );
372 REQUIRE( dig.remotePort() == 86 );
375 WHEN(
"no remote port in second tunnel" )
377 mx::app::writeConfigFile(
"/tmp/sshDigger_test.conf",
378 {
"tunnel1",
"tunnel1",
"tunnel1",
"tunnel2",
"tunnel2" },
379 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort" },
380 {
"exao2",
"80",
"81",
"exao3",
"85" } );
382 mx::app::appConfigurator config;
383 config.readConfig(
"/tmp/sshDigger_test.conf" );
386 dig.configName(
"tunnel2" );
388 rv = dig.loadConfigImpl( config );
391 dig.configName(
"tunnel1" );
393 rv = dig.loadConfigImpl( config );
395 REQUIRE( dig.remoteHost() ==
"exao2" );
396 REQUIRE( dig.localPort() == 80 );
397 REQUIRE( dig.remotePort() == 81 );