File tests/wh_http.php changed (mode: 100644) (index 5aa4f88..08db757) |
... |
... |
rg_log('port1=' . $port1 . ' port2=' . $port2 . ' port3=' . $port3); |
27 |
27 |
|
|
28 |
28 |
function clean() |
function clean() |
29 |
29 |
{ |
{ |
30 |
|
rg_exec('fuser -k -9 wh-stunnel-1.log', '', FALSE, FALSE); |
|
31 |
|
rg_exec('fuser -k -9 wh-stunnel-2.log', '', FALSE, FALSE); |
|
32 |
|
rg_exec('fuser -k -9 wh-stunnel-3.log', '', FALSE, FALSE); |
|
33 |
|
|
|
34 |
|
@unlink('wh-stunnel.conf-1.tmp'); |
|
35 |
|
@unlink('wh-stunnel.conf-2.tmp'); |
|
36 |
|
@unlink('wh-stunnel.conf-3.tmp'); |
|
|
30 |
|
rg_log_enter('clean'); |
|
31 |
|
for ($id = 1; $id <= 3; $id++) { |
|
32 |
|
rg_exec('fuser -k -9 wh-stunnel-' . $id . '.log', '', FALSE, FALSE); |
|
33 |
|
@unlink('wh-stunnel.conf-' . $id . '.tmp'); |
|
34 |
|
} |
|
35 |
|
rg_log_exit(); |
37 |
36 |
} |
} |
38 |
|
register_shutdown_function('clean'); |
|
39 |
37 |
|
|
40 |
38 |
prepare_http(); |
prepare_http(); |
41 |
39 |
|
|
|
... |
... |
if ($x === FALSE) { |
60 |
58 |
$y = str_replace('@@port@@', $port1, $x); |
$y = str_replace('@@port@@', $port1, $x); |
61 |
59 |
$y = str_replace('@@verify@@', '2', $y); |
$y = str_replace('@@verify@@', '2', $y); |
62 |
60 |
$y = str_replace('@@id@@', '1', $y); |
$y = str_replace('@@id@@', '1', $y); |
|
61 |
|
$y = str_replace('@@cwd@@', __DIR__, $y); |
63 |
62 |
file_put_contents('wh-stunnel.conf-1.tmp', $y); |
file_put_contents('wh-stunnel.conf-1.tmp', $y); |
64 |
63 |
|
|
65 |
64 |
$y = str_replace('@@port@@', $port2, $x); |
$y = str_replace('@@port@@', $port2, $x); |
66 |
65 |
$y = str_replace('@@verify@@', '2', $y); |
$y = str_replace('@@verify@@', '2', $y); |
67 |
66 |
$y = str_replace('@@id@@', '2', $y); |
$y = str_replace('@@id@@', '2', $y); |
|
67 |
|
$y = str_replace('@@cwd@@', __DIR__, $y); |
68 |
68 |
file_put_contents('wh-stunnel.conf-2.tmp', $y); |
file_put_contents('wh-stunnel.conf-2.tmp', $y); |
69 |
69 |
|
|
70 |
70 |
$y = str_replace('@@port@@', $port3, $x); |
$y = str_replace('@@port@@', $port3, $x); |
71 |
71 |
$y = str_replace('@@verify@@', '0', $y); |
$y = str_replace('@@verify@@', '0', $y); |
72 |
72 |
$y = str_replace('@@id@@', '3', $y); |
$y = str_replace('@@id@@', '3', $y); |
|
73 |
|
$y = str_replace('@@cwd@@', __DIR__, $y); |
73 |
74 |
file_put_contents('wh-stunnel.conf-3.tmp', $y); |
file_put_contents('wh-stunnel.conf-3.tmp', $y); |
74 |
75 |
|
|
75 |
76 |
|
|
|
... |
... |
if ($pid == 0) { //child |
115 |
116 |
rg_log('Started stunnel with pid ' . $pid); |
rg_log('Started stunnel with pid ' . $pid); |
116 |
117 |
|
|
117 |
118 |
|
|
|
119 |
|
register_shutdown_function('clean'); |
|
120 |
|
|
118 |
121 |
rg_log(''); |
rg_log(''); |
119 |
122 |
rg_log("Creating a user..."); |
rg_log("Creating a user..."); |
120 |
123 |
rg_test_create_user($db, $rg_ui); |
rg_test_create_user($db, $rg_ui); |
|
... |
... |
rg_test_create_repo($db, $rg_ui, $repo); |
225 |
228 |
|
|
226 |
229 |
|
|
227 |
230 |
rg_log(''); |
rg_log(''); |
228 |
|
rg_log('Testing if the curl posted with success (wh1)'); |
|
|
231 |
|
rg_log('Testing if the curl posted with success (wh1) (should not work)'); |
229 |
232 |
for ($i = 0; $i < 10; $i++) { |
for ($i = 0; $i < 10; $i++) { |
230 |
233 |
$r = rg_cache_get($key1 . '::' . $wh_id1); |
$r = rg_cache_get($key1 . '::' . $wh_id1); |
231 |
234 |
rg_log_ml('cache: ' . $r); |
rg_log_ml('cache: ' . $r); |
|
... |
... |
if ($r === FALSE) { |
238 |
241 |
exit(1); |
exit(1); |
239 |
242 |
} |
} |
240 |
243 |
if (strcmp($r, "BAD") != 0) { |
if (strcmp($r, "BAD") != 0) { |
|
244 |
|
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id1 . '::last_output'; |
|
245 |
|
$_e = rg_cache_get($_k); |
241 |
246 |
rg_log('Seems wh1 executed correctly without client' |
rg_log('Seems wh1 executed correctly without client' |
242 |
247 |
. ' cert (r=' . $r . ')!'); |
. ' cert (r=' . $r . ')!'); |
|
248 |
|
rg_log_ml($_e); |
243 |
249 |
exit(1); |
exit(1); |
244 |
250 |
} |
} |
245 |
251 |
|
|
246 |
252 |
|
|
247 |
253 |
rg_log(''); |
rg_log(''); |
248 |
|
rg_log('Testing if the curl posted with success (wh2)'); |
|
|
254 |
|
rg_log('Testing if the curl posted with success (wh2) (should work)'); |
249 |
255 |
for ($i = 0; $i < 10; $i++) { |
for ($i = 0; $i < 10; $i++) { |
250 |
256 |
$r = rg_cache_get($key2 . '::' . $wh_id2); |
$r = rg_cache_get($key2 . '::' . $wh_id2); |
251 |
257 |
rg_log_ml('cache: ' . print_r($r, TRUE)); |
rg_log_ml('cache: ' . print_r($r, TRUE)); |
|
... |
... |
for ($i = 0; $i < 10; $i++) { |
254 |
260 |
sleep(1); |
sleep(1); |
255 |
261 |
} |
} |
256 |
262 |
if (strcmp($r, "OK") != 0) { |
if (strcmp($r, "OK") != 0) { |
|
263 |
|
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id2 . '::last_output'; |
|
264 |
|
$_e = rg_cache_get($_k); |
257 |
265 |
rg_log('Seems wh2 did not returned success' |
rg_log('Seems wh2 did not returned success' |
258 |
266 |
. ' (r=' . $r . ')!'); |
. ' (r=' . $r . ')!'); |
|
267 |
|
rg_log_ml($_e); |
259 |
268 |
exit(1); |
exit(1); |
260 |
269 |
} |
} |
261 |
270 |
|
|
262 |
271 |
|
|
263 |
272 |
rg_log(''); |
rg_log(''); |
264 |
|
rg_log('Testing if the curl posted with success (wh3)'); |
|
|
273 |
|
rg_log('Testing if the curl posted with success (wh3) (should work)'); |
265 |
274 |
for ($i = 0; $i < 10; $i++) { |
for ($i = 0; $i < 10; $i++) { |
266 |
275 |
$r = rg_cache_get($key3 . '::' . $wh_id3); |
$r = rg_cache_get($key3 . '::' . $wh_id3); |
267 |
276 |
rg_log_ml('cache: ' . print_r($r, TRUE)); |
rg_log_ml('cache: ' . print_r($r, TRUE)); |
|
... |
... |
for ($i = 0; $i < 10; $i++) { |
270 |
279 |
sleep(1); |
sleep(1); |
271 |
280 |
} |
} |
272 |
281 |
if (strcmp($r, "OK") != 0) { |
if (strcmp($r, "OK") != 0) { |
|
282 |
|
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id3 . '::last_output'; |
|
283 |
|
$_e = rg_cache_get($_k); |
273 |
284 |
rg_log('Seems wh3 did not returned success' |
rg_log('Seems wh3 did not returned success' |
274 |
285 |
. ' (r=' . $r . ')!'); |
. ' (r=' . $r . ')!'); |
|
286 |
|
rg_log_ml($_e); |
275 |
287 |
exit(1); |
exit(1); |
276 |
288 |
} |
} |
277 |
289 |
|
|