File tests/helpers.inc.php changed (mode: 100644) (index 9d498e9..55c29c6) |
... |
... |
function rg_test_create_repo($db, $rg_ui, &$extra) |
148 |
148 |
|
|
149 |
149 |
$r = rg_repo_edit($db, $rg_ui, $extra); |
$r = rg_repo_edit($db, $rg_ui, $extra); |
150 |
150 |
if ($r === FALSE) { |
if ($r === FALSE) { |
151 |
|
rg_log("Cannot insert a repo (" . rg_repo_error() . ")!"); |
|
|
151 |
|
rg_log("Cannot insert a repo (" . rg_repo_error() . ")!"); |
152 |
152 |
exit(1); |
exit(1); |
153 |
153 |
} |
} |
154 |
154 |
|
|
|
... |
... |
function rg_test_create_key($db, $rg_ui) |
197 |
197 |
|
|
198 |
198 |
$r = rg_keys_add($db, $rg_ui, $skey); |
$r = rg_keys_add($db, $rg_ui, $skey); |
199 |
199 |
if ($r === FALSE) { |
if ($r === FALSE) { |
200 |
|
rg_log("Cannot add a key (" . rg_keys_error() . ")!"); |
|
|
200 |
|
rg_log("Cannot add a key (" . rg_keys_error() . ")!"); |
201 |
201 |
exit(1); |
exit(1); |
202 |
202 |
} |
} |
203 |
203 |
|
|
|
... |
... |
function rg_test_upload_ssh_key($db, $rg_ui, $key_name, $good_sid) |
293 |
293 |
} |
} |
294 |
294 |
if (empty($r['tokens']['keys'])) { |
if (empty($r['tokens']['keys'])) { |
295 |
295 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
296 |
|
rg_log('token not found!'); |
|
297 |
|
exit(1); |
|
|
296 |
|
rg_log('token not found!'); |
|
297 |
|
exit(1); |
298 |
298 |
} |
} |
299 |
299 |
|
|
300 |
300 |
rg_log("Uploading the key..."); |
rg_log("Uploading the key..."); |
|
... |
... |
function rg_test_sc_generate($db, $rg_ui, $good_sid) |
341 |
341 |
} |
} |
342 |
342 |
if (empty($r['tokens']['sc'])) { |
if (empty($r['tokens']['sc'])) { |
343 |
343 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
344 |
|
rg_log('token not found!'); |
|
345 |
|
exit(1); |
|
|
344 |
|
rg_log('token not found!'); |
|
345 |
|
exit(1); |
346 |
346 |
} |
} |
347 |
347 |
|
|
348 |
348 |
rg_log("Generating scratch codes..."); |
rg_log("Generating scratch codes..."); |
|
... |
... |
function rg_test_wh_add_edit($db, $rg_ui, $good_sid, $htype, $extra) |
391 |
391 |
} |
} |
392 |
392 |
if (empty($r['tokens']['wh_add'])) { |
if (empty($r['tokens']['wh_add'])) { |
393 |
393 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
394 |
|
rg_log_ml('Token not found!'); |
|
395 |
|
exit(1); |
|
|
394 |
|
rg_log_ml('Token not found!'); |
|
395 |
|
exit(1); |
396 |
396 |
} |
} |
397 |
397 |
|
|
398 |
398 |
rg_log("Adding webhook..."); |
rg_log("Adding webhook..."); |
File tests/http_confirm.php changed (mode: 100644) (index d6c2705..8c1a476) |
... |
... |
rg_log_exit(); |
88 |
88 |
|
|
89 |
89 |
rg_log_enter('Trying with the wrong link...'); |
rg_log_enter('Trying with the wrong link...'); |
90 |
90 |
$data = array(); $headers = array(); |
$data = array(); $headers = array(); |
91 |
|
$r = do_req($link . 'XXX?rg_debug=1&t=http_confirm', $data, $headers); |
|
|
91 |
|
$r = do_req($link . 'XXX?t=http_confirm', $data, $headers); |
92 |
92 |
if (!strstr($r['body'], 'Invalid token')) { |
if (!strstr($r['body'], 'Invalid token')) { |
93 |
93 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
94 |
94 |
rg_log('Somethign wrong with the token!'); |
rg_log('Somethign wrong with the token!'); |
|
... |
... |
rg_log_exit(); |
98 |
98 |
|
|
99 |
99 |
|
|
100 |
100 |
rg_log_enter('Trying with the good link...'); |
rg_log_enter('Trying with the good link...'); |
101 |
|
$r = do_req($link . '?rg_debug=1&t=http_confirm', $data, $headers); |
|
|
101 |
|
$r = do_req($link . '?t=http_confirm', $data, $headers); |
102 |
102 |
if (!strstr($r['body'], 'Home page of user')) { |
if (!strstr($r['body'], 'Home page of user')) { |
103 |
103 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
104 |
104 |
rg_log('Somethign wrong with the token!'); |
rg_log('Somethign wrong with the token!'); |
File tests/http_keys.php added (mode: 100644) (index 0000000..fc51b0a) |
|
1 |
|
<?php |
|
2 |
|
error_reporting(E_ALL | E_STRICT); |
|
3 |
|
ini_set('track_errors', 'On'); |
|
4 |
|
|
|
5 |
|
$rg_cache_debug = TRUE; |
|
6 |
|
|
|
7 |
|
$INC = dirname(__FILE__) . '/../inc'; |
|
8 |
|
require_once(dirname(__FILE__) . '/config.php'); |
|
9 |
|
require_once($INC . '/init.inc.php'); |
|
10 |
|
require_once($INC . '/util.inc.php'); |
|
11 |
|
require_once('helpers.inc.php'); |
|
12 |
|
require_once('http.inc.php'); |
|
13 |
|
|
|
14 |
|
rg_log_set_file('http_keys.log'); |
|
15 |
|
|
|
16 |
|
$rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10'; |
|
17 |
|
$rg_no_db = TRUE; |
|
18 |
|
require_once('common.php'); |
|
19 |
|
|
|
20 |
|
$_testns = 'http_keys'; |
|
21 |
|
$rg_cache_enable = TRUE; |
|
22 |
|
$rg_cache_debug = TRUE; |
|
23 |
|
|
|
24 |
|
$rg_ui = array('is_admin' => 1); |
|
25 |
|
rg_test_create_user($db, $rg_ui); |
|
26 |
|
test_login($test_url, $rg_ui, $good_sid); |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
rg_log(''); |
|
30 |
|
rg_log_enter('Loading Admin -> Settings -> SSH...'); |
|
31 |
|
$data = array(); |
|
32 |
|
$headers = array("Cookie: sid=" . $good_sid); |
|
33 |
|
$r = do_req($test_url . '/op/admin/settings/ssh', $data, $headers); |
|
34 |
|
if ($r === FALSE) { |
|
35 |
|
rg_log("Cannot load page!"); |
|
36 |
|
exit(1); |
|
37 |
|
} |
|
38 |
|
if (!isset($r['tokens']['admin_settings_ssh'])) { |
|
39 |
|
rg_log_ml('r:' . print_r($r, TRUE)); |
|
40 |
|
rg_log("No token?!"); |
|
41 |
|
exit(1); |
|
42 |
|
} |
|
43 |
|
$token = $r['tokens']['admin_settings_ssh']; |
|
44 |
|
|
|
45 |
|
rg_log('Posting the form...'); |
|
46 |
|
$data = array( |
|
47 |
|
'doit' => 1, |
|
48 |
|
'token' => $token |
|
49 |
|
); |
|
50 |
|
$list = array( |
|
51 |
|
'max_ssh_keys' => 10, |
|
52 |
|
'ssh_key_min_bits_rsa' => 2048, |
|
53 |
|
'ssh_key_allow_dsa' => 0, |
|
54 |
|
'ssh_key_min_bits_ecdsa' => 256, |
|
55 |
|
'AuthorizedKeysCommand' => 1 |
|
56 |
|
); |
|
57 |
|
foreach ($list as $var => $def) { |
|
58 |
|
$v = rg_state_get($db, $var); |
|
59 |
|
if ($v === FALSE) { |
|
60 |
|
rg_log('Cannot load state!'); |
|
61 |
|
exit(1); |
|
62 |
|
} |
|
63 |
|
if (empty($v)) |
|
64 |
|
$data[$var] = $def; |
|
65 |
|
else |
|
66 |
|
$data[$var] = $v; |
|
67 |
|
} |
|
68 |
|
$r = do_req($test_url . '/op/admin/settings/ssh', $data, $headers); |
|
69 |
|
if (!strstr($r['body'], 'Configuration has been successfully saved.')) { |
|
70 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
71 |
|
rg_log("Cannot post form!"); |
|
72 |
|
exit(1); |
|
73 |
|
} |
|
74 |
|
rg_log_exit(); |
|
75 |
|
|
|
76 |
|
|
|
77 |
|
rg_log('OK!'); |
|
78 |
|
?> |
File tests/repo.php changed (mode: 100644) (index 0b6bba9..1d25d4c) |
... |
... |
$first = array_shift($copy); |
259 |
259 |
$c = isset($first['rights']) ? $first['rights'] : "_BAD_"; |
$c = isset($first['rights']) ? $first['rights'] : "_BAD_"; |
260 |
260 |
if (strcmp($c, $e) != 0) { |
if (strcmp($c, $e) != 0) { |
261 |
261 |
rg_log_ml("rights_get: r=" . print_r($r, TRUE)); |
rg_log_ml("rights_get: r=" . print_r($r, TRUE)); |
262 |
|
rg_log("Non-owner (uid " . $a['uid']. ") did not get correct rights: c=$c e=$e."); |
|
|
262 |
|
rg_log("Non-owner (uid " . $a['uid']. ") did not get correct rights: c=$c e=$e."); |
263 |
263 |
exit(1); |
exit(1); |
264 |
264 |
} |
} |
265 |
265 |
rg_log_exit(); |
rg_log_exit(); |