File tests/email.php changed (mode: 100644) (index a5b64b9..bd9fad0) |
2 |
2 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
|
5 |
|
$test_normal = TRUE; |
|
6 |
|
|
5 |
7 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
8 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
7 |
9 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
|
... |
... |
require_once("helpers.inc.php"); |
10 |
12 |
|
|
11 |
13 |
rg_log_set_file("email.log"); |
rg_log_set_file("email.log"); |
12 |
14 |
|
|
13 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
14 |
|
$rg_no_db = TRUE; |
|
15 |
15 |
require_once("common.php"); |
require_once("common.php"); |
16 |
16 |
|
|
17 |
17 |
$_testns = 'email'; |
$_testns = 'email'; |
|
... |
... |
rg_test_create_user($db, $rg_ui); |
28 |
28 |
rg_log(''); |
rg_log(''); |
29 |
29 |
rg_log('Trying to get the cache info...'); |
rg_log('Trying to get the cache info...'); |
30 |
30 |
$key = 'DEBUG::' . $rg_ui['uid']; |
$key = 'DEBUG::' . $rg_ui['uid']; |
31 |
|
$tries = 10; |
|
32 |
|
while ($tries--) { |
|
33 |
|
$r = rg_cache_get($key); |
|
34 |
|
if ($r === FALSE) { |
|
35 |
|
sleep(1); |
|
36 |
|
continue; |
|
37 |
|
} |
|
38 |
|
|
|
39 |
|
break; |
|
40 |
|
} |
|
41 |
|
if ($r === FALSE) { |
|
42 |
|
rg_log('DEBUG key was not set!'); |
|
43 |
|
exit(1); |
|
44 |
|
} |
|
|
31 |
|
$r = test_wait_cache($key); |
45 |
32 |
if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['realname'])) { |
if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['realname'])) { |
46 |
33 |
rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE)); |
rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE)); |
47 |
34 |
rg_log('realname was specified bu not found in e-mail!'); |
rg_log('realname was specified bu not found in e-mail!'); |
|
... |
... |
rg_test_create_user($db, $rg_ui); |
58 |
45 |
rg_log(''); |
rg_log(''); |
59 |
46 |
rg_log('Trying to get the cache info...'); |
rg_log('Trying to get the cache info...'); |
60 |
47 |
$key = 'DEBUG::' . $rg_ui['uid']; |
$key = 'DEBUG::' . $rg_ui['uid']; |
61 |
|
$tries = 10; |
|
62 |
|
while ($tries--) { |
|
63 |
|
$r = rg_cache_get($key); |
|
64 |
|
if ($r === FALSE) { |
|
65 |
|
sleep(1); |
|
66 |
|
continue; |
|
67 |
|
} |
|
68 |
|
|
|
69 |
|
break; |
|
70 |
|
} |
|
71 |
|
if ($r === FALSE) { |
|
72 |
|
rg_log('DEBUG key was not set!'); |
|
73 |
|
exit(1); |
|
74 |
|
} |
|
|
48 |
|
$r = test_wait_cache($key); |
75 |
49 |
if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['username'])) { |
if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['username'])) { |
76 |
50 |
rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE)); |
rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE)); |
77 |
51 |
rg_log('realname was specified bu not found in e-mail!'); |
rg_log('realname was specified bu not found in e-mail!'); |
File tests/git2.php changed (mode: 100644) (index 423f66b..1788fa9) |
2 |
2 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
|
5 |
|
$test_normal = TRUE; |
|
6 |
|
|
5 |
7 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
8 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
7 |
9 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
|
... |
... |
require_once("http.inc.php"); |
11 |
13 |
|
|
12 |
14 |
rg_log_set_file("git2.log"); |
rg_log_set_file("git2.log"); |
13 |
15 |
|
|
14 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
15 |
|
$rg_no_db = TRUE; |
|
16 |
16 |
require_once("common.php"); |
require_once("common.php"); |
17 |
17 |
|
|
18 |
18 |
$_testns = 'git2'; |
$_testns = 'git2'; |
|
... |
... |
if ($r === FALSE) { |
55 |
55 |
} |
} |
56 |
56 |
|
|
57 |
57 |
|
|
58 |
|
rg_log(''); |
|
59 |
|
rg_log_enter('Uploading a key...'); |
|
60 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'git2'); |
|
61 |
|
rg_log_exit(); |
|
62 |
|
|
|
|
58 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'git2', $kn); |
|
59 |
|
putenv('GIT_SSH_COMMAND=ssh -o IdentityFile=../keys/' . $kn |
|
60 |
|
. ' -o IdentitiesOnly=yes'); |
63 |
61 |
|
|
64 |
62 |
rg_log(''); |
rg_log(''); |
65 |
63 |
rg_log_enter('Trying to push master...'); |
rg_log_enter('Trying to push master...'); |
|
... |
... |
$remote = 'ssh://rocketgit@' . $rg_ssh_host . ':' .$rg_ssh_port |
67 |
65 |
. '/user/' . escapeshellarg($rg_ui['username']) |
. '/user/' . escapeshellarg($rg_ui['username']) |
68 |
66 |
. '/' . escapeshellarg($repo['name']); |
. '/' . escapeshellarg($repo['name']); |
69 |
67 |
$r = rg_exec("cd git2 && git remote add origin $remote" |
$r = rg_exec("cd git2 && git remote add origin $remote" |
70 |
|
. " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2 -o IdentitiesOnly=yes\"" |
|
71 |
68 |
. " && git push origin master", |
. " && git push origin master", |
72 |
69 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
|
70 |
|
if ($r['ok'] != 1) { |
|
71 |
|
rg_log_ml('out: ' . print_r($r, TRUE)); |
|
72 |
|
rg_log('Seems I cannot push master!'); |
|
73 |
|
exit(1); |
|
74 |
|
} |
|
75 |
|
rg_log_exit(); |
|
76 |
|
|
|
77 |
|
|
|
78 |
|
rg_log(''); |
|
79 |
|
rg_log_enter('Go back one commit and try to push (must fail)...'); |
|
80 |
|
$r = rg_exec("cd git2 && git reset hard HEAD^1" |
|
81 |
|
. " && git push origin master", |
|
82 |
|
'', FALSE, FALSE, FALSE); |
|
83 |
|
if ($r['ok'] == 1) { |
|
84 |
|
rg_log('Seems I can push master and I must not!'); |
|
85 |
|
exit(1); |
|
86 |
|
} |
|
87 |
|
rg_log_exit(); |
|
88 |
|
|
|
89 |
|
|
|
90 |
|
rg_log(''); |
|
91 |
|
rg_log_enter('Go back one commit and try to push (force)...'); |
|
92 |
|
$r = rg_exec("cd git2 && git push --force origin master", |
|
93 |
|
'', FALSE, FALSE, FALSE); |
73 |
94 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
74 |
95 |
rg_log_ml('out: ' . $r['errmsg']); |
rg_log_ml('out: ' . $r['errmsg']); |
75 |
|
rg_log("Seems I cannot push master! err=$err"); |
|
|
96 |
|
rg_log("Seems I cannot force push the master! err=$err"); |
76 |
97 |
exit(1); |
exit(1); |
77 |
98 |
} |
} |
78 |
99 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
rg_log_exit(); |
80 |
101 |
|
|
81 |
102 |
rg_log(''); |
rg_log(''); |
82 |
103 |
rg_log_enter('Trying to push tags...'); |
rg_log_enter('Trying to push tags...'); |
83 |
|
$r = rg_exec("cd git2" |
|
84 |
|
. " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2 -o IdentitiesOnly=yes\"" |
|
85 |
|
. " && git push --tags origin", |
|
|
104 |
|
$r = rg_exec("cd git2 && git push --tags", |
86 |
105 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
87 |
106 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
88 |
107 |
rg_log_ml('error: ' . $r['errmsg']); |
rg_log_ml('error: ' . $r['errmsg']); |
|
... |
... |
rg_log_exit(); |
93 |
112 |
|
|
94 |
113 |
|
|
95 |
114 |
$commit = trim(file_get_contents('git2/.git/refs/heads/master')); |
$commit = trim(file_get_contents('git2/.git/refs/heads/master')); |
96 |
|
rg_log("Load master from .git: $commit"); |
|
|
115 |
|
rg_log("Loaded master from .git: $commit"); |
97 |
116 |
|
|
98 |
117 |
rg_log(''); |
rg_log(''); |
99 |
118 |
rg_log_enter('Checking on web that everything is OK...'); |
rg_log_enter('Checking on web that everything is OK...'); |
|
... |
... |
rg_log(''); |
127 |
146 |
rg_log_enter('Delete a branch must make it disappear also from web...'); |
rg_log_enter('Delete a branch must make it disappear also from web...'); |
128 |
147 |
// Pushing a branch |
// Pushing a branch |
129 |
148 |
$r = rg_exec("cd git2" |
$r = rg_exec("cd git2" |
130 |
|
. " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2 -o IdentitiesOnly=yes\"" |
|
131 |
149 |
. " && git checkout -b branch22" |
. " && git checkout -b branch22" |
132 |
150 |
. " && git push origin branch22", |
. " && git push origin branch22", |
133 |
151 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
|
... |
... |
if ($r['ok'] != 1) { |
137 |
155 |
exit(1); |
exit(1); |
138 |
156 |
} |
} |
139 |
157 |
// Deleting the branch |
// Deleting the branch |
140 |
|
$r = rg_exec("cd git2" |
|
141 |
|
. " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2 -o IdentitiesOnly=yes\"" |
|
142 |
|
. " && git push origin :branch22", |
|
|
158 |
|
$r = rg_exec("cd git2 && git push origin :branch22", |
143 |
159 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
144 |
160 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
145 |
161 |
rg_log_ml('out: ' . $r['errmsg']); |
rg_log_ml('out: ' . $r['errmsg']); |
File tests/git_log1.expected changed (mode: 100644) (index 5c6993e..93c2881) |
1 |
1 |
<div class="diff"> |
<div class="diff"> |
2 |
|
<br /> |
|
3 |
2 |
<a name="file-uniq-id-b9a1399c1280298cc14674769cff87a0a785e6ab"></a> |
<a name="file-uniq-id-b9a1399c1280298cc14674769cff87a0a785e6ab"></a> |
4 |
3 |
<table class="chunk"> |
<table class="chunk"> |
5 |
4 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
|
8 |
7 |
</table> |
</table> |
9 |
8 |
</div> |
</div> |
10 |
9 |
<div class="diff"> |
<div class="diff"> |
11 |
|
<br /> |
|
12 |
10 |
<a name="file-uniq-id-b9a1399c1280298cc14674769cff87a0a785e6ab"></a> |
<a name="file-uniq-id-b9a1399c1280298cc14674769cff87a0a785e6ab"></a> |
13 |
11 |
<table class="chunk"> |
<table class="chunk"> |
14 |
12 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
15 |
13 |
</table> |
</table> |
16 |
14 |
</div> |
</div> |
17 |
15 |
<div class="diff"> |
<div class="diff"> |
18 |
|
<br /> |
|
19 |
16 |
<a name="file-uniq-id-9c7aa2b11f270998a63b1b1795cff3890a4eb56f"></a> |
<a name="file-uniq-id-9c7aa2b11f270998a63b1b1795cff3890a4eb56f"></a> |
20 |
17 |
<table class="chunk"> |
<table class="chunk"> |
21 |
18 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
|
24 |
21 |
</table> |
</table> |
25 |
22 |
</div> |
</div> |
26 |
23 |
<div class="diff"> |
<div class="diff"> |
27 |
|
<br /> |
|
28 |
24 |
<a name="file-uniq-id-9c7aa2b11f270998a63b1b1795cff3890a4eb56f"></a> |
<a name="file-uniq-id-9c7aa2b11f270998a63b1b1795cff3890a4eb56f"></a> |
29 |
25 |
<table class="chunk"> |
<table class="chunk"> |
30 |
26 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
31 |
27 |
</table> |
</table> |
32 |
28 |
</div> |
</div> |
33 |
29 |
<div class="diff"> |
<div class="diff"> |
34 |
|
<br /> |
|
35 |
30 |
<a name="file-uniq-id-08f42ca259cf121d2ea9cd8b6c5b24c86d733db7"></a> |
<a name="file-uniq-id-08f42ca259cf121d2ea9cd8b6c5b24c86d733db7"></a> |
36 |
31 |
<table class="chunk"> |
<table class="chunk"> |
37 |
32 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
|
40 |
35 |
</table> |
</table> |
41 |
36 |
</div> |
</div> |
42 |
37 |
<div class="diff"> |
<div class="diff"> |
43 |
|
<br /> |
|
44 |
38 |
<a name="file-uniq-id-08f42ca259cf121d2ea9cd8b6c5b24c86d733db7"></a> |
<a name="file-uniq-id-08f42ca259cf121d2ea9cd8b6c5b24c86d733db7"></a> |
45 |
39 |
<table class="chunk"> |
<table class="chunk"> |
46 |
40 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
47 |
41 |
</table> |
</table> |
48 |
42 |
</div> |
</div> |
49 |
43 |
<div class="diff"> |
<div class="diff"> |
50 |
|
<br /> |
|
51 |
44 |
<a name="file-uniq-id-e9ead85f4cc2dfffaae3cd00d6f14cb099922f0c"></a> |
<a name="file-uniq-id-e9ead85f4cc2dfffaae3cd00d6f14cb099922f0c"></a> |
52 |
45 |
<table class="chunk"> |
<table class="chunk"> |
53 |
46 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\1\2\3\4\5\6\a\b\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37 !"#$%&'()*+,-.0123456789:;<=>?</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\1\2\3\4\5\6\a\b\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37 !"#$%&'()*+,-.0123456789:;<=>?</b> changed (mode: 100644) (index 72943a1..f761ec1)</td></tr> |
|
56 |
49 |
</table> |
</table> |
57 |
50 |
</div> |
</div> |
58 |
51 |
<div class="diff"> |
<div class="diff"> |
59 |
|
<br /> |
|
60 |
52 |
<a name="file-uniq-id-e9ead85f4cc2dfffaae3cd00d6f14cb099922f0c"></a> |
<a name="file-uniq-id-e9ead85f4cc2dfffaae3cd00d6f14cb099922f0c"></a> |
61 |
53 |
<table class="chunk"> |
<table class="chunk"> |
62 |
54 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\1\2\3\4\5\6\a\b\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37 !"#$%&'()*+,-.0123456789:;<=>?</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>\1\2\3\4\5\6\a\b\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37 !"#$%&'()*+,-.0123456789:;<=>?</b> copied from file <b>a b c È™</b> (similarity 100%)</td></tr> |
63 |
55 |
</table> |
</table> |
64 |
56 |
</div> |
</div> |
65 |
57 |
<div class="diff"> |
<div class="diff"> |
66 |
|
<br /> |
|
67 |
58 |
<a name="file-uniq-id-e57f9914bcbd958506a4a7148bcd0fa6b2f49b8d"></a> |
<a name="file-uniq-id-e57f9914bcbd958506a4a7148bcd0fa6b2f49b8d"></a> |
68 |
59 |
<table class="chunk"> |
<table class="chunk"> |
69 |
60 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>dis1</b> changed (mode: 100644) (index 2c4179b..2bf9115)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>dis1</b> changed (mode: 100644) (index 2c4179b..2bf9115)</td></tr> |
|
73 |
64 |
</table> |
</table> |
74 |
65 |
</div> |
</div> |
75 |
66 |
<div class="diff"> |
<div class="diff"> |
76 |
|
<br /> |
|
77 |
67 |
<a name="file-uniq-id-e57f9914bcbd958506a4a7148bcd0fa6b2f49b8d"></a> |
<a name="file-uniq-id-e57f9914bcbd958506a4a7148bcd0fa6b2f49b8d"></a> |
78 |
68 |
<table class="chunk"> |
<table class="chunk"> |
79 |
69 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>dis1</b> added (mode: 100644) (index 0000000..2c4179b)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>dis1</b> added (mode: 100644) (index 0000000..2c4179b)</td></tr> |
|
82 |
72 |
</table> |
</table> |
83 |
73 |
</div> |
</div> |
84 |
74 |
<div class="diff"> |
<div class="diff"> |
85 |
|
<br /> |
|
86 |
75 |
<a name="file-uniq-id-039b389972b4d0ed5fabf08adece44f7a64a1152"></a> |
<a name="file-uniq-id-039b389972b4d0ed5fabf08adece44f7a64a1152"></a> |
87 |
76 |
<table class="chunk"> |
<table class="chunk"> |
88 |
77 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b> b\a\b</b> added (mode: 100644) (index 0000000..a9a1f63)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b> b\a\b</b> added (mode: 100644) (index 0000000..a9a1f63)</td></tr> |
|
90 |
79 |
</table> |
</table> |
91 |
80 |
</div> |
</div> |
92 |
81 |
<div class="diff"> |
<div class="diff"> |
93 |
|
<br /> |
|
94 |
82 |
<a name="file-uniq-id-d97bde1f426a49de70c1be6772fe99215766f3a3"></a> |
<a name="file-uniq-id-d97bde1f426a49de70c1be6772fe99215766f3a3"></a> |
95 |
83 |
<table class="chunk"> |
<table class="chunk"> |
96 |
84 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a b c<xss></b> added (mode: 100644) (index 0000000..e19d72a)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a b c<xss></b> added (mode: 100644) (index 0000000..e19d72a)</td></tr> |
|
98 |
86 |
</table> |
</table> |
99 |
87 |
</div> |
</div> |
100 |
88 |
<div class="diff"> |
<div class="diff"> |
101 |
|
<br /> |
|
102 |
89 |
<a name="file-uniq-id-a958c33024ce45b9785fa950e1e9e21e9b655337"></a> |
<a name="file-uniq-id-a958c33024ce45b9785fa950e1e9e21e9b655337"></a> |
103 |
90 |
<table class="chunk"> |
<table class="chunk"> |
104 |
91 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a b c È™</b> added (mode: 100644) (index 0000000..72943a1)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a b c È™</b> added (mode: 100644) (index 0000000..72943a1)</td></tr> |
|
106 |
93 |
</table> |
</table> |
107 |
94 |
</div> |
</div> |
108 |
95 |
<div class="diff"> |
<div class="diff"> |
109 |
|
<br /> |
|
110 |
96 |
<a name="file-uniq-id-252bc06763afb3b6c2a0802f7346700ab55f46f5"></a> |
<a name="file-uniq-id-252bc06763afb3b6c2a0802f7346700ab55f46f5"></a> |
111 |
97 |
<table class="chunk"> |
<table class="chunk"> |
112 |
98 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a3</b> deleted (index 193814c..0000000)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a3</b> deleted (index 193814c..0000000)</td></tr> |
|
114 |
100 |
</table> |
</table> |
115 |
101 |
</div> |
</div> |
116 |
102 |
<div class="diff"> |
<div class="diff"> |
117 |
|
<br /> |
|
118 |
103 |
<a name="file-uniq-id-252bc06763afb3b6c2a0802f7346700ab55f46f5"></a> |
<a name="file-uniq-id-252bc06763afb3b6c2a0802f7346700ab55f46f5"></a> |
119 |
104 |
<table class="chunk"> |
<table class="chunk"> |
120 |
105 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a3</b> renamed from <b>a2</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a3</b> renamed from <b>a2</b> (similarity 100%)</td></tr> |
121 |
106 |
</table> |
</table> |
122 |
|
<br /> |
|
123 |
107 |
<a name="file-uniq-id-84a516841ba77a5b4648de2cd0dfcb30ea46dbb4"></a> |
<a name="file-uniq-id-84a516841ba77a5b4648de2cd0dfcb30ea46dbb4"></a> |
124 |
108 |
<table class="chunk"> |
<table class="chunk"> |
125 |
109 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>c</b> added (mode: 100644) (index 0000000..8ded189)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>c</b> added (mode: 100644) (index 0000000..8ded189)</td></tr> |
|
127 |
111 |
</table> |
</table> |
128 |
112 |
</div> |
</div> |
129 |
113 |
<div class="diff"> |
<div class="diff"> |
130 |
|
<br /> |
|
131 |
114 |
<a name="file-uniq-id-b9f85daa6f83cf02ce5c31913d1f64d3f5c8fade"></a> |
<a name="file-uniq-id-b9f85daa6f83cf02ce5c31913d1f64d3f5c8fade"></a> |
132 |
115 |
<table class="chunk"> |
<table class="chunk"> |
133 |
116 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a2</b> copied from file <b>a</b> (similarity 100%)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a2</b> copied from file <b>a</b> (similarity 100%)</td></tr> |
134 |
117 |
</table> |
</table> |
135 |
118 |
</div> |
</div> |
136 |
119 |
<div class="diff"> |
<div class="diff"> |
137 |
|
<br /> |
|
138 |
120 |
<a name="file-uniq-id-2f2c3aed7ef52985dbc835f7a091c91a69ad6ebb"></a> |
<a name="file-uniq-id-2f2c3aed7ef52985dbc835f7a091c91a69ad6ebb"></a> |
139 |
121 |
<table class="chunk"> |
<table class="chunk"> |
140 |
122 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>empty.txt</b> added (mode: 100644) (index 0000000..e69de29)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>empty.txt</b> added (mode: 100644) (index 0000000..e69de29)</td></tr> |
141 |
123 |
</table> |
</table> |
142 |
124 |
</div> |
</div> |
143 |
125 |
<div class="diff"> |
<div class="diff"> |
144 |
|
<br /> |
|
145 |
126 |
<a name="file-uniq-id-b7418c54bc2eb2de8dcb3c02b69d853e2feb3c92"></a> |
<a name="file-uniq-id-b7418c54bc2eb2de8dcb3c02b69d853e2feb3c92"></a> |
146 |
127 |
<table class="chunk"> |
<table class="chunk"> |
147 |
128 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>xx"yy</b> added (mode: 100644) (index 0000000..1678aa7)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>xx"yy</b> added (mode: 100644) (index 0000000..1678aa7)</td></tr> |
|
149 |
130 |
</table> |
</table> |
150 |
131 |
</div> |
</div> |
151 |
132 |
<div class="diff"> |
<div class="diff"> |
152 |
|
<br /> |
|
153 |
133 |
<a name="file-uniq-id-86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"></a> |
<a name="file-uniq-id-86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"></a> |
154 |
134 |
<table class="chunk"> |
<table class="chunk"> |
155 |
135 |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a</b> added (mode: 100644) (index 0000000..193814c)</td></tr> |
<tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a</b> added (mode: 100644) (index 0000000..193814c)</td></tr> |
File tests/helpers.inc.php changed (mode: 100644) (index ea362d8..5108906) |
... |
... |
function rg_test_create_user($db, &$rg_ui) |
105 |
105 |
} |
} |
106 |
106 |
|
|
107 |
107 |
/* |
/* |
108 |
|
* Creating a repo helper |
|
109 |
|
* You can enforce a repo-id by setting extra['repo_id']. |
|
|
108 |
|
* Creating a repo helper; see rg_test_create_repo() |
110 |
109 |
*/ |
*/ |
111 |
110 |
$_repo_id = 1; |
$_repo_id = 1; |
112 |
|
function rg_test_create_repo($db, $rg_ui, &$extra) |
|
|
111 |
|
function rg_test_create_repo_no_dir($db, $rg_ui, &$extra) |
113 |
112 |
{ |
{ |
114 |
113 |
global $_testns; |
global $_testns; |
115 |
114 |
global $_repo_id; |
global $_repo_id; |
|
... |
... |
function rg_test_create_repo($db, $rg_ui, &$extra) |
119 |
118 |
|
|
120 |
119 |
$repo_id = isset($extra['repo_id']) ? $extra['repo_id'] : 0; |
$repo_id = isset($extra['repo_id']) ? $extra['repo_id'] : 0; |
121 |
120 |
|
|
122 |
|
rg_log("Creating a repo"); |
|
|
121 |
|
rg_log('Creating a repo with id ' . $repo_id); |
123 |
122 |
$new = array(); |
$new = array(); |
124 |
123 |
$new['master'] = 0; |
$new['master'] = 0; |
125 |
124 |
if (isset($extra['name'])) |
if (isset($extra['name'])) |
126 |
125 |
$new['name'] = $extra['name']; |
$new['name'] = $extra['name']; |
127 |
126 |
else |
else |
128 |
|
$new['name'] = $_testns . '-repo-' . $_repo_id . '<xss>'; |
|
|
127 |
|
$new['name'] = $_testns . '-repo-' . $_repo_id . '<xss>' . rand(); |
129 |
128 |
$new['max_commit_size'] = 0; |
$new['max_commit_size'] = 0; |
130 |
129 |
$new['description'] = 'desc line1\ndesc line2' . '<xss>'; |
$new['description'] = 'desc line1\ndesc line2' . '<xss>'; |
131 |
130 |
$new['git_dir_done'] = 0; |
$new['git_dir_done'] = 0; |
|
... |
... |
function rg_test_create_repo($db, $rg_ui, &$extra) |
165 |
164 |
rg_cache_unset('repo_by_name::' . $rg_ui['uid'], |
rg_cache_unset('repo_by_name::' . $rg_ui['uid'], |
166 |
165 |
RG_SOCKET_NO_WAIT); |
RG_SOCKET_NO_WAIT); |
167 |
166 |
} |
} |
|
167 |
|
} |
|
168 |
|
|
|
169 |
|
/* |
|
170 |
|
* Creating a repo helper |
|
171 |
|
* You can enforce a repo-name/repo-id by setting extra['name/repo_id']. |
|
172 |
|
*/ |
|
173 |
|
function rg_test_create_repo($db, $rg_ui, &$extra) |
|
174 |
|
{ |
|
175 |
|
rg_test_create_repo_no_dir($db, $rg_ui, $extra); |
168 |
176 |
|
|
169 |
|
rg_log('Waiting for the repo git dir to be created...'); |
|
170 |
177 |
$key = 'repo_by_id' . '::' . $extra['repo_id']; |
$key = 'repo_by_id' . '::' . $extra['repo_id']; |
171 |
|
$tries = 10; |
|
172 |
|
while ($tries-- > 0) { |
|
173 |
|
rg_cache_core_unset($key); |
|
|
178 |
|
rg_log('Waiting for the repo git dir to be created (key [' . $key . '])...'); |
|
179 |
|
$tries = 50; |
|
180 |
|
while ($tries > 0) { |
|
181 |
|
$tries--; |
174 |
182 |
|
|
|
183 |
|
rg_cache_core_unset($key); |
175 |
184 |
$r = rg_cache_get($key); |
$r = rg_cache_get($key); |
176 |
185 |
if ($r === FALSE) { |
if ($r === FALSE) { |
177 |
|
rg_log('r is FALSE'); |
|
178 |
186 |
sleep(1); |
sleep(1); |
179 |
187 |
continue; |
continue; |
180 |
188 |
} |
} |
|
... |
... |
function rg_test_create_repo($db, $rg_ui, &$extra) |
186 |
194 |
|
|
187 |
195 |
sleep(1); |
sleep(1); |
188 |
196 |
} |
} |
189 |
|
|
|
190 |
|
return TRUE; |
|
|
197 |
|
if ($tries === 0) { |
|
198 |
|
rg_log('Seems that the git folder was not created!'); |
|
199 |
|
exit(1); |
|
200 |
|
} |
191 |
201 |
} |
} |
192 |
202 |
|
|
193 |
203 |
/* |
/* |
|
... |
... |
function rg_test_create_repo($db, $rg_ui, &$extra) |
196 |
206 |
function rg_test_create_key($db, $rg_ui) |
function rg_test_create_key($db, $rg_ui) |
197 |
207 |
{ |
{ |
198 |
208 |
rg_log("Creating a key"); |
rg_log("Creating a key"); |
199 |
|
// spaces are on purpose |
|
|
209 |
|
// spaces are on purpose, to test that we remove them correctly |
200 |
210 |
$skey = 'ssh-rsa AAAAB3Nz aC1yc2EAAAADA QABAAABAQDgy8QSbr13izfGxO0sqOsxu4faw6hF1LLrlcBobT5zzO4wzbokjliRiZ9sfA0zd0WEfdQJ6W01hVNf9QpJlUiGM4OyXBKOc8JLfCyjtcfRcC48hPQ22IY9TtfrxGK38IgwdS7+Ophjs8u0RlqHd8eMtYWcmxlHwdIEb6+IZ6kyA2srmFGN6DQCnOvyYSd+iZ8u4DQBEuWxzsKvrat9gR5H6KNTYisSB9rjLKQd4rFbu6Tl217wJY1LWjH7hlFPxioMCg0Fzv6AkQXWnAr1GrCVgIQDC5dEVUrw2NSVElEC+eaG6OZnkq7CP0B8pSj3BV2TNhSgnQb9Ojo9xNHc2Pwx aaa@aaa.aaa'; |
$skey = 'ssh-rsa AAAAB3Nz aC1yc2EAAAADA QABAAABAQDgy8QSbr13izfGxO0sqOsxu4faw6hF1LLrlcBobT5zzO4wzbokjliRiZ9sfA0zd0WEfdQJ6W01hVNf9QpJlUiGM4OyXBKOc8JLfCyjtcfRcC48hPQ22IY9TtfrxGK38IgwdS7+Ophjs8u0RlqHd8eMtYWcmxlHwdIEb6+IZ6kyA2srmFGN6DQCnOvyYSd+iZ8u4DQBEuWxzsKvrat9gR5H6KNTYisSB9rjLKQd4rFbu6Tl217wJY1LWjH7hlFPxioMCg0Fzv6AkQXWnAr1GrCVgIQDC5dEVUrw2NSVElEC+eaG6OZnkq7CP0B8pSj3BV2TNhSgnQb9Ojo9xNHc2Pwx aaa@aaa.aaa'; |
201 |
211 |
|
|
202 |
212 |
$r = rg_keys_add($db, $rg_ui, $skey); |
$r = rg_keys_add($db, $rg_ui, $skey); |
|
... |
... |
function rg_test_create_bug($db, $rg_ui, $ri, &$extra) |
268 |
278 |
* Helper for creating and uploading a ssh key |
* Helper for creating and uploading a ssh key |
269 |
279 |
* Returns the key. |
* Returns the key. |
270 |
280 |
*/ |
*/ |
271 |
|
function rg_test_upload_ssh_key($db, $rg_ui, $key_name) |
|
|
281 |
|
function rg_test_upload_ssh_key($db, $rg_ui, $key_suffix, &$key_name) |
272 |
282 |
{ |
{ |
273 |
283 |
global $test_url; |
global $test_url; |
274 |
284 |
|
|
|
285 |
|
$key_name = $rg_ui['uid'] . $key_suffix; |
|
286 |
|
putenv('RG_SSH_KEY=' . $key_name); |
|
287 |
|
|
275 |
288 |
// we must regenerate the key because else we will not be the correct user |
// we must regenerate the key because else we will not be the correct user |
276 |
|
rg_log("Generating a SSH key [$key_name]"); |
|
|
289 |
|
rg_log_enter("Generating a SSH key [$key_name]"); |
277 |
290 |
if (file_exists('keys/' . $key_name)) |
if (file_exists('keys/' . $key_name)) |
278 |
291 |
unlink('keys/' . $key_name); |
unlink('keys/' . $key_name); |
279 |
292 |
if (file_exists('keys/' . $key_name . '.pub')) |
if (file_exists('keys/' . $key_name . '.pub')) |
|
... |
... |
function rg_test_upload_ssh_key($db, $rg_ui, $key_name) |
328 |
341 |
} |
} |
329 |
342 |
} |
} |
330 |
343 |
rg_log("Uploading done"); |
rg_log("Uploading done"); |
|
344 |
|
rg_log_exit(); |
331 |
345 |
|
|
332 |
346 |
return $key; |
return $key; |
333 |
347 |
} |
} |
|
... |
... |
function rg_test_wh_add_edit($db, $rg_ui, $htype, $extra) |
428 |
442 |
* Check if a pull request hit the database |
* Check if a pull request hit the database |
429 |
443 |
* Returns the row or exits |
* Returns the row or exits |
430 |
444 |
*/ |
*/ |
431 |
|
function rg_test_mr_in_db($db, $repo_id) |
|
|
445 |
|
function rg_test_mr_info($db, $repo_id, $nr) |
432 |
446 |
{ |
{ |
433 |
|
rg_log_enter('Check if the pull request is in database...'); |
|
|
447 |
|
rg_log_enter('Check if the pull request ' . $nr . ' is in database...'); |
434 |
448 |
$tries = 10; |
$tries = 10; |
435 |
449 |
while ($tries > 0) { |
while ($tries > 0) { |
|
450 |
|
$params = array('nr' => $nr); |
436 |
451 |
$sql = 'SELECT * FROM merge_requests' |
$sql = 'SELECT * FROM merge_requests' |
437 |
452 |
. ' WHERE repo_id = ' . $repo_id |
. ' WHERE repo_id = ' . $repo_id |
438 |
|
. ' AND done = 0'; |
|
439 |
|
$res = rg_sql_query($db, $sql); |
|
|
453 |
|
. ' AND id = @@nr@@'; |
|
454 |
|
$res = rg_sql_query_params($db, $sql, $params); |
440 |
455 |
$rows = rg_sql_num_rows($res); |
$rows = rg_sql_num_rows($res); |
441 |
456 |
if ($rows > 0) |
if ($rows > 0) |
442 |
457 |
$row = rg_sql_fetch_array($res); |
$row = rg_sql_fetch_array($res); |
|
... |
... |
function rg_test_mr_in_db($db, $repo_id) |
457 |
472 |
} |
} |
458 |
473 |
|
|
459 |
474 |
/* |
/* |
460 |
|
* |
|
|
475 |
|
* Run ssh command, using a generated key |
461 |
476 |
*/ |
*/ |
462 |
477 |
function test_ssh($uid, $extra) |
function test_ssh($uid, $extra) |
463 |
478 |
{ |
{ |
464 |
479 |
global $rg_ssh_host, $rg_ssh_port; |
global $rg_ssh_host, $rg_ssh_port; |
465 |
480 |
|
|
|
481 |
|
$kn = getenv('RG_SSH_KEY'); |
|
482 |
|
|
466 |
483 |
$cmd = 'ssh -v' |
$cmd = 'ssh -v' |
467 |
|
. ' -i keys/' . $uid |
|
|
484 |
|
. ' -i keys/' . $kn |
468 |
485 |
. ' -p ' . $rg_ssh_port |
. ' -p ' . $rg_ssh_port |
469 |
486 |
. ' -o ControlMaster=no' |
. ' -o ControlMaster=no' |
470 |
487 |
. ' -o ControlPath=' . __DIR__ . '/jars/ssh-' . $uid |
. ' -o ControlPath=' . __DIR__ . '/jars/ssh-' . $uid |
|
... |
... |
function test_ssh($uid, $extra) |
473 |
490 |
return rg_exec($cmd . ' ' . $extra, '', FALSE, FALSE, FALSE); |
return rg_exec($cmd . ' ' . $extra, '', FALSE, FALSE, FALSE); |
474 |
491 |
} |
} |
475 |
492 |
|
|
476 |
|
?> |
|
|
493 |
|
/* |
|
494 |
|
* Wait for a value in cache |
|
495 |
|
*/ |
|
496 |
|
function test_wait_cache($key) |
|
497 |
|
{ |
|
498 |
|
for ($i = 0; $i < 50; $i++) { |
|
499 |
|
rg_cache_core_unset($key); |
|
500 |
|
$r = rg_cache_get($key); |
|
501 |
|
if ($r !== FALSE) |
|
502 |
|
break; |
|
503 |
|
sleep(1); |
|
504 |
|
} |
|
505 |
|
|
|
506 |
|
if ($r === FALSE) { |
|
507 |
|
rg_log('Could not obtain a value from cache for key [' . $key . ']!'); |
|
508 |
|
exit(1); |
|
509 |
|
} |
|
510 |
|
|
|
511 |
|
return $r; |
|
512 |
|
} |
|
513 |
|
|
File tests/hook_update.sh changed (mode: 100755) (index cfe9a8d..a4a2e2b) |
2 |
2 |
|
|
3 |
3 |
tests=`pwd` |
tests=`pwd` |
4 |
4 |
|
|
|
5 |
|
src="${tests}/repos/hook_update_src.git" |
|
6 |
|
dest="${tests}/repos/hook_update_dest.git" |
|
7 |
|
|
5 |
8 |
export ROCKETGIT_CONF_FILE="`pwd`/config.php" |
export ROCKETGIT_CONF_FILE="`pwd`/config.php" |
6 |
9 |
export ROCKETGIT_LOGIN_UID=1234 |
export ROCKETGIT_LOGIN_UID=1234 |
7 |
10 |
export ROCKETGIT_REPO_ID=5678 |
export ROCKETGIT_REPO_ID=5678 |
8 |
11 |
export ROCKETGIT_IP="127.0.0.1" |
export ROCKETGIT_IP="127.0.0.1" |
9 |
|
export ROCKETGIT_REPO_PATH="`pwd`/hook_update_dest.git" |
|
|
12 |
|
export ROCKETGIT_REPO_PATH="${dest}" |
10 |
13 |
export ROCKETGIT_REPO_UID=22 |
export ROCKETGIT_REPO_UID=22 |
|
14 |
|
export ROCKETGIT_UTIL_DEBUG=1 |
11 |
15 |
|
|
12 |
|
rm -rf hook_update_*.git |
|
13 |
|
mkdir hook_update_dest.git |
|
|
16 |
|
rm -rf repos/hook_update_*.git |
|
17 |
|
mkdir -p "${dest}" |
14 |
18 |
( |
( |
15 |
|
cd hook_update_dest.git |
|
|
19 |
|
cd "${dest}" |
16 |
20 |
git init --bare |
git init --bare |
17 |
21 |
) |
) |
18 |
|
cp -v ../hooks/update hook_update_dest.git/hooks/ |
|
|
22 |
|
cp -v ../hooks/update "${dest}/hooks/" |
19 |
23 |
|
|
20 |
24 |
ln -sf ../../root/themes/default themes/ |
ln -sf ../../root/themes/default themes/ |
21 |
25 |
|
|
22 |
|
git clone hook_update_dest.git hook_update_src.git |
|
|
26 |
|
git clone "${dest}" "${src}" |
23 |
27 |
|
|
24 |
|
cd hook_update_src.git |
|
|
28 |
|
cd "${src}" |
25 |
29 |
|
|
26 |
30 |
php ${tests}/hook_update_help.php init |
php ${tests}/hook_update_help.php init |
27 |
31 |
if [ "${?}" != "0" ]; then |
if [ "${?}" != "0" ]; then |
|
... |
... |
git commit -m "new b" a |
131 |
135 |
git checkout master |
git checkout master |
132 |
136 |
echo "a" > b; git add b |
echo "a" > b; git add b |
133 |
137 |
git commit -m "c" b |
git commit -m "c" b |
134 |
|
git merge -m "x" branch1 |
|
|
138 |
|
git tag ret_point |
|
139 |
|
git merge -m "this is a merge" branch1 |
|
140 |
|
# Add a commit to see if we test all commits, not only the last one |
|
141 |
|
echo "aaasasa" >> b; git add b; git commit -m "d" |
135 |
142 |
git push origin master |
git push origin master |
136 |
143 |
if [ "${?}" != "1" ]; then |
if [ "${?}" != "1" ]; then |
137 |
144 |
echo "Should not work!" |
echo "Should not work!" |
|
... |
... |
if [ "${?}" != "0" ]; then |
145 |
152 |
echo "Should work!" |
echo "Should work!" |
146 |
153 |
exit 1 |
exit 1 |
147 |
154 |
fi |
fi |
|
155 |
|
# Because we test anonymous push, we need to throw away the merge commit |
|
156 |
|
git reset --hard ret_point |
|
157 |
|
git push --force origin master |
148 |
158 |
|
|
149 |
159 |
echo |
echo |
150 |
160 |
echo "=== Testing bad-whitespace without rights..." |
echo "=== Testing bad-whitespace without rights..." |
|
... |
... |
export GIT_NAMESPACE="hook_update_ns1" |
224 |
234 |
echo "xx" > b; git add b |
echo "xx" > b; git add b |
225 |
235 |
git commit -m "preparing for anonymous push" b |
git commit -m "preparing for anonymous push" b |
226 |
236 |
# We need to do this because it is done in remote.php that we do not call here |
# We need to do this because it is done in remote.php that we do not call here |
227 |
|
X="../hook_update_dest.git/refs/namespaces/${GIT_NAMESPACE}/refs/heads" |
|
|
237 |
|
X="${dest}/refs/namespaces/${GIT_NAMESPACE}/refs/heads" |
228 |
238 |
mkdir -p ${X} |
mkdir -p ${X} |
229 |
|
cp -a ../hook_update_dest.git/refs/heads/* "${X}/" |
|
|
239 |
|
cp -a "${dest}"/refs/heads/* "${X}/" |
230 |
240 |
echo "=== Testing anonymous push without rights..." |
echo "=== Testing anonymous push without rights..." |
231 |
241 |
#strace -s200 -ff -o ${tests}/hook_update.strace \ |
#strace -s200 -ff -o ${tests}/hook_update.strace \ |
232 |
242 |
git push origin master |
git push origin master |
|
... |
... |
if [ "${?}" != "0" ]; then |
243 |
253 |
exit 1 |
exit 1 |
244 |
254 |
fi |
fi |
245 |
255 |
# Test if the namespace has been updated instead of main namespace |
# Test if the namespace has been updated instead of main namespace |
246 |
|
A=`diff ../hook_update_dest.git/refs/namespaces/${GIT_NAMESPACE}/refs/heads/master \ |
|
|
256 |
|
A=`diff "${dest}/refs/namespaces/${GIT_NAMESPACE}/refs/heads/master" \ |
247 |
257 |
.git/refs/heads/master` |
.git/refs/heads/master` |
248 |
258 |
if [ "${?}" != 0 ]; then |
if [ "${?}" != 0 ]; then |
249 |
259 |
echo "Cannot do the diff for anonymous push" |
echo "Cannot do the diff for anonymous push" |
|
... |
... |
if [ "${A}" != "" ]; then |
253 |
263 |
echo "We did not update the namespace!" |
echo "We did not update the namespace!" |
254 |
264 |
exit 1 |
exit 1 |
255 |
265 |
fi |
fi |
256 |
|
A=`diff ../hook_update_dest.git/refs/heads/master \ |
|
257 |
|
.git/refs/heads/master` |
|
|
266 |
|
A=`diff "${dest}/refs/heads/master" .git/refs/heads/master` |
258 |
267 |
if [ "${A}" = "" ]; then |
if [ "${A}" = "" ]; then |
259 |
268 |
echo "Seems we updated also main namespace!" |
echo "Seems we updated also main namespace!" |
260 |
269 |
exit 1 |
exit 1 |
|
... |
... |
if [ "${?}" != 0 ]; then |
287 |
296 |
echo "Cannot do the diff for anonymous push" |
echo "Cannot do the diff for anonymous push" |
288 |
297 |
exit 1 |
exit 1 |
289 |
298 |
fi |
fi |
290 |
|
A=`diff ../hook_update_dest.git/refs/namespaces/${GIT_NAMESPACE}/refs/heads/branch_anon1 \ |
|
|
299 |
|
A=`diff "${dest}/refs/namespaces/${GIT_NAMESPACE}/refs/heads/branch_anon1" \ |
291 |
300 |
.git/refs/heads/branch_anon1` |
.git/refs/heads/branch_anon1` |
292 |
301 |
if [ "${A}" != "" ]; then |
if [ "${A}" != "" ]; then |
293 |
302 |
echo "We did not update the namespace but main refs (anon+branch)!" |
echo "We did not update the namespace but main refs (anon+branch)!" |
294 |
303 |
exit 1 |
exit 1 |
295 |
304 |
fi |
fi |
296 |
|
A=`diff ../hook_update_dest.git/refs/heads/master \ |
|
297 |
|
.git/refs/heads/branch_anon1` |
|
|
305 |
|
A=`diff "${dest}/refs/heads/master" .git/refs/heads/branch_anon1` |
298 |
306 |
if [ "${A}" = "" ]; then |
if [ "${A}" = "" ]; then |
299 |
307 |
echo "Seems we updated also main refs (anon+branch)!" |
echo "Seems we updated also main refs (anon+branch)!" |
300 |
308 |
exit 1 |
exit 1 |
|
... |
... |
fi |
303 |
311 |
|
|
304 |
312 |
cd .. |
cd .. |
305 |
313 |
|
|
306 |
|
rm -rf hook_update_*.git |
|
307 |
|
|
|
308 |
314 |
echo "hook_pre-update: OK!"; |
echo "hook_pre-update: OK!"; |
File tests/http_settings.php changed (mode: 100644) (index c9f3806..3e1fd29) |
... |
... |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
5 |
5 |
$rg_cache_debug = TRUE; |
$rg_cache_debug = TRUE; |
|
6 |
|
$test_normal = TRUE; |
6 |
7 |
|
|
7 |
8 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
8 |
9 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
|
... |
... |
require_once("http.inc.php"); |
13 |
14 |
|
|
14 |
15 |
rg_log_set_file("http_settings.log"); |
rg_log_set_file("http_settings.log"); |
15 |
16 |
|
|
16 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
17 |
|
$rg_no_db = TRUE; |
|
18 |
17 |
require_once("common.php"); |
require_once("common.php"); |
19 |
18 |
|
|
20 |
19 |
$_testns = 'http_settings'; |
$_testns = 'http_settings'; |
|
... |
... |
prepare_http(); |
24 |
23 |
|
|
25 |
24 |
$now = time(); |
$now = time(); |
26 |
25 |
|
|
27 |
|
rg_log("Testing if caching works: cache_enable=" . ($rg_cache_enable ? "true" : "false")); |
|
|
26 |
|
rg_log_enter("Testing if caching works: cache_enable=" . ($rg_cache_enable ? "true" : "false")); |
28 |
27 |
rg_cache_set("test::a", "1", 0); |
rg_cache_set("test::a", "1", 0); |
29 |
28 |
rg_cache_core_unset("test::a"); // to force "network" access = bypass mem cache |
rg_cache_core_unset("test::a"); // to force "network" access = bypass mem cache |
30 |
29 |
$r = rg_cache_get("test::a"); |
$r = rg_cache_get("test::a"); |
|
... |
... |
if ($r !== FALSE) { |
39 |
38 |
rg_log("Main cache (unset) is not working!"); |
rg_log("Main cache (unset) is not working!"); |
40 |
39 |
exit(1); |
exit(1); |
41 |
40 |
} |
} |
|
41 |
|
rg_log_exit(); |
42 |
42 |
|
|
43 |
43 |
test_restore($db); |
test_restore($db); |
44 |
44 |
|
|
|
... |
... |
if ($r === FALSE) { |
50 |
50 |
} |
} |
51 |
51 |
|
|
52 |
52 |
rg_log(''); |
rg_log(''); |
53 |
|
rg_log("Loading change pass form"); |
|
|
53 |
|
rg_log_enter("Loading change pass form"); |
54 |
54 |
$data = array(); |
$data = array(); |
55 |
55 |
$headers = array(); |
$headers = array(); |
56 |
56 |
$r = do_req($test_url . "/op/settings/change_pass?t=load_change_pass_form", $data, $headers); |
$r = do_req($test_url . "/op/settings/change_pass?t=load_change_pass_form", $data, $headers); |
|
... |
... |
if (!strstr($r['body'], "action=\"/op/settings/change_pass\"")) { |
60 |
60 |
exit(1); |
exit(1); |
61 |
61 |
} |
} |
62 |
62 |
$good_token = $r['tokens']['set_pass']; |
$good_token = $r['tokens']['set_pass']; |
|
63 |
|
rg_log_exit(); |
63 |
64 |
|
|
64 |
65 |
rg_log(''); |
rg_log(''); |
65 |
|
rg_log("Posting change pass form"); |
|
|
66 |
|
rg_log_enter('Posting change pass form'); |
66 |
67 |
$data = array( |
$data = array( |
67 |
68 |
"doit" => 1, |
"doit" => 1, |
68 |
69 |
"token" => $good_token, |
"token" => $good_token, |
|
... |
... |
if (!strstr($r['body'], "Password has been successfully updated")) { |
77 |
78 |
rg_log("Cannot change pass!"); |
rg_log("Cannot change pass!"); |
78 |
79 |
exit(1); |
exit(1); |
79 |
80 |
} |
} |
|
81 |
|
rg_log_exit(); |
80 |
82 |
|
|
81 |
83 |
|
|
82 |
84 |
rg_log(''); |
rg_log(''); |
83 |
|
rg_log("Now, try to login with the old password"); |
|
|
85 |
|
rg_log_enter('Now, try to login with the old password'); |
84 |
86 |
$r2 = test_login($test_url, $rg_ui); |
$r2 = test_login($test_url, $rg_ui); |
85 |
87 |
if ($r2 !== FALSE) { |
if ($r2 !== FALSE) { |
86 |
88 |
rg_log("Seems we were able to login with the old password!"); |
rg_log("Seems we were able to login with the old password!"); |
87 |
89 |
exit(1); |
exit(1); |
88 |
90 |
|
|
89 |
91 |
} |
} |
|
92 |
|
rg_log_exit(); |
90 |
93 |
|
|
91 |
94 |
|
|
92 |
95 |
rg_log(''); |
rg_log(''); |
93 |
|
rg_log("Change back the password"); |
|
|
96 |
|
rg_log_enter('Change back the password'); |
94 |
97 |
$data = array(); |
$data = array(); |
95 |
98 |
$headers = array(); |
$headers = array(); |
96 |
99 |
$r = do_req($test_url . "/op/settings/change_pass?t=load_change_pass_form", $data, $headers); |
$r = do_req($test_url . "/op/settings/change_pass?t=load_change_pass_form", $data, $headers); |
|
... |
... |
if ($r === FALSE) { |
113 |
116 |
rg_log("Cannot change back the pass to aaaa!"); |
rg_log("Cannot change back the pass to aaaa!"); |
114 |
117 |
exit(1); |
exit(1); |
115 |
118 |
} |
} |
|
119 |
|
rg_log_exit(); |
116 |
120 |
|
|
117 |
121 |
|
|
118 |
122 |
rg_log(''); |
rg_log(''); |
119 |
|
rg_log("Testing edit info section"); |
|
|
123 |
|
rg_log_enter("Testing edit info section"); |
120 |
124 |
|
|
121 |
125 |
rg_log(''); |
rg_log(''); |
122 |
|
rg_log("Loading edit info form"); |
|
|
126 |
|
rg_log_enter('Loading edit info form'); |
123 |
127 |
$data = array(); |
$data = array(); |
124 |
128 |
$headers = array(); |
$headers = array(); |
125 |
129 |
$r = do_req($test_url . "/op/settings/edit_info?t=load_edit_info_form", $data, $headers); |
$r = do_req($test_url . "/op/settings/edit_info?t=load_edit_info_form", $data, $headers); |
|
... |
... |
if ($r === FALSE) { |
128 |
132 |
rg_log("Cannot load form!"); |
rg_log("Cannot load form!"); |
129 |
133 |
exit(1); |
exit(1); |
130 |
134 |
} |
} |
|
135 |
|
rg_log_exit(); |
131 |
136 |
|
|
132 |
137 |
rg_log(''); |
rg_log(''); |
133 |
|
rg_log("Posting edit info form"); |
|
|
138 |
|
rg_log_enter('Posting edit info form'); |
134 |
139 |
$session_time = intval($now / 393956); |
$session_time = intval($now / 393956); |
135 |
140 |
$data = array( |
$data = array( |
136 |
141 |
"doit" => 1, |
"doit" => 1, |
|
... |
... |
if (!strstr($r['body'], "Information has been successfully updated")) { |
148 |
153 |
rg_log("Cannot change account info!"); |
rg_log("Cannot change account info!"); |
149 |
154 |
exit(1); |
exit(1); |
150 |
155 |
} |
} |
|
156 |
|
rg_log_exit(); |
151 |
157 |
|
|
152 |
158 |
rg_log(''); |
rg_log(''); |
153 |
|
rg_log("Verify against database"); |
|
|
159 |
|
rg_log_enter('Verify against database'); |
154 |
160 |
$sql = "SELECT * FROM users WHERE username = '" . $rg_ui['username'] . "'"; |
$sql = "SELECT * FROM users WHERE username = '" . $rg_ui['username'] . "'"; |
155 |
161 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
156 |
162 |
$row = rg_sql_fetch_array($res); |
$row = rg_sql_fetch_array($res); |
|
... |
... |
if ($row['session_time'] != $session_time) { |
170 |
176 |
rg_log_ml("session_time has not been changed: " . print_r($row, TRUE)); |
rg_log_ml("session_time has not been changed: " . print_r($row, TRUE)); |
171 |
177 |
exit(1); |
exit(1); |
172 |
178 |
} |
} |
|
179 |
|
rg_log_exit(); |
|
180 |
|
|
|
181 |
|
rg_log_exit(); |
173 |
182 |
|
|
174 |
183 |
|
|
175 |
184 |
rg_log(''); |
rg_log(''); |
176 |
|
rg_log("Testing SSH keys"); |
|
177 |
|
$key = rg_test_upload_ssh_key($db, $rg_ui, 'http_settings'); |
|
|
185 |
|
rg_log_enter('Testing SSH keys'); |
|
186 |
|
$key = rg_test_upload_ssh_key($db, $rg_ui, 'http_settings', $kn); |
178 |
187 |
$key = trim($key); |
$key = trim($key); |
179 |
188 |
// the key upload stuff will change < and > to empty. |
// the key upload stuff will change < and > to empty. |
180 |
189 |
$sql = "SELECT * FROM keys WHERE key = '" . $key . "'"; |
$sql = "SELECT * FROM keys WHERE key = '" . $key . "'"; |
|
... |
... |
if ($rows == 0) { |
189 |
198 |
exit(1); |
exit(1); |
190 |
199 |
} |
} |
191 |
200 |
$key_id = $row['key_id']; |
$key_id = $row['key_id']; |
|
201 |
|
rg_log_exit(); |
|
202 |
|
|
192 |
203 |
|
|
193 |
204 |
rg_log(''); |
rg_log(''); |
194 |
|
rg_log("Now, testing deletion: key_id=$key_id"); |
|
|
205 |
|
rg_log_enter('Now, testing deletion: key_id=' . $key_id); |
195 |
206 |
rg_log("Loading ssh keys form"); |
rg_log("Loading ssh keys form"); |
196 |
207 |
$data = array(); |
$data = array(); |
197 |
208 |
$headers = array(); |
$headers = array(); |
|
... |
... |
if ($rows == 1) { |
219 |
230 |
rg_log("key $key_id has not been deleted!"); |
rg_log("key $key_id has not been deleted!"); |
220 |
231 |
exit(1); |
exit(1); |
221 |
232 |
} |
} |
|
233 |
|
rg_log_exit(); |
222 |
234 |
|
|
223 |
235 |
rg_log("OK!"); |
rg_log("OK!"); |
224 |
236 |
?> |
?> |
File tests/mr.inc.php added (mode: 100644) (index 0000000..24e3d00) |
|
1 |
|
<?php |
|
2 |
|
|
|
3 |
|
/* |
|
4 |
|
* Check pull request operations |
|
5 |
|
* @expect_ff - TRUE if we expect a fast-forward to take place, |
|
6 |
|
* even if merge_ff is 0. |
|
7 |
|
*/ |
|
8 |
|
function test_mr_check($db, $t, $rg_ui, $repo, $mr_id, $mr_refname, $expect_ff) |
|
9 |
|
{ |
|
10 |
|
global $test_url; |
|
11 |
|
|
|
12 |
|
rg_log_enter('test_mr_check'); |
|
13 |
|
|
|
14 |
|
$url = '/user/' . $rg_ui['username'] . '/' . $repo['name'] . '/mr'; |
|
15 |
|
|
|
16 |
|
rg_log_enter('Check if merge is in db and is against correct branch...'); |
|
17 |
|
$mri = rg_test_mr_info($db, $repo['repo_id'], $mr_id); |
|
18 |
|
if (strcmp($mri['refname'], $mr_refname) != 0) { |
|
19 |
|
rg_log_ml('mri: ' . print_r($mri, TRUE)); |
|
20 |
|
rg_log('Seems the ref is not [' . $mr_refname . ']: ' . $mri['refname'] . '!'); |
|
21 |
|
exit(1); |
|
22 |
|
} |
|
23 |
|
rg_log_exit(); |
|
24 |
|
|
|
25 |
|
|
|
26 |
|
rg_log(''); |
|
27 |
|
rg_log_enter('Loading the merge requests page - just to see it appears there'); |
|
28 |
|
$data = array(); |
|
29 |
|
$headers = array(); |
|
30 |
|
$r = do_req($test_url . $url . '?t=' . $t, $data, $headers); |
|
31 |
|
if (!strstr($r['body'], '>' . $mri['id'] . '<')) { |
|
32 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
33 |
|
rg_log('id link not found!'); |
|
34 |
|
exit(1); |
|
35 |
|
} |
|
36 |
|
rg_log_exit(); |
|
37 |
|
|
|
38 |
|
|
|
39 |
|
rg_log(''); |
|
40 |
|
rg_log_enter('Loading the merge request specific page...'); |
|
41 |
|
$data = array(); |
|
42 |
|
$headers = array(); |
|
43 |
|
$r = do_req($test_url . $url . '/' . $mri['id'] . '?t=' . $t, $data, $headers); |
|
44 |
|
if (!strstr($r['body'], 'This pull request can be merged without conflicts')) { |
|
45 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
46 |
|
rg_log('Merge request does not appear as mergeable'); |
|
47 |
|
exit(1); |
|
48 |
|
} |
|
49 |
|
rg_log_exit(); |
|
50 |
|
|
|
51 |
|
|
|
52 |
|
rg_log(''); |
|
53 |
|
rg_log_enter('Merging merge request...'); |
|
54 |
|
$mm1 = 'This is the merge message <xss>' . rg_id(8); |
|
55 |
|
$data = array('token' => $r['tokens']['mr_merge'], |
|
56 |
|
'merge_ff' => 0, 'merge_msg' => $mm1); |
|
57 |
|
$r = do_req($test_url . $url . '/' . $mri['id'] . '/merge', $data, $headers); |
|
58 |
|
if ($r === FALSE) { |
|
59 |
|
rg_log('Cannot post merge form'); |
|
60 |
|
exit(1); |
|
61 |
|
} |
|
62 |
|
$tries = 0; |
|
63 |
|
while (1) { |
|
64 |
|
$sql = 'SELECT * FROM merge_requests' |
|
65 |
|
. ' WHERE repo_id = ' . $repo['repo_id'] |
|
66 |
|
. ' AND done > 0 AND id = ' . $mri['id']; |
|
67 |
|
$res = rg_sql_query($db, $sql); |
|
68 |
|
$rows = rg_sql_num_rows($res); |
|
69 |
|
rg_sql_free_result($res); |
|
70 |
|
if ($rows == 1) |
|
71 |
|
break; |
|
72 |
|
|
|
73 |
|
if ($tries == 10) { |
|
74 |
|
rg_log('merge_request was not marked as done in db!'); |
|
75 |
|
exit(1); |
|
76 |
|
} |
|
77 |
|
$tries++; |
|
78 |
|
sleep(1); |
|
79 |
|
} |
|
80 |
|
|
|
81 |
|
$r = rg_exec('cd temp_repos/pr_anon' |
|
82 |
|
. ' && git pull origin_git master', |
|
83 |
|
'', FALSE, FALSE, FALSE); |
|
84 |
|
if ($r['ok'] != 1) { |
|
85 |
|
rg_log('Could not pull: ' . $r['errmsg'] . '!'); |
|
86 |
|
exit(1); |
|
87 |
|
} |
|
88 |
|
|
|
89 |
|
if ($expect_ff) |
|
90 |
|
$add = ' --merges'; |
|
91 |
|
else |
|
92 |
|
$add = ''; |
|
93 |
|
$r = rg_exec('cd temp_repos/pr_anon && git log --oneline -n1' . $add, |
|
94 |
|
'', FALSE, FALSE, FALSE); |
|
95 |
|
if ($r['ok'] != 1) { |
|
96 |
|
rg_log('Could not generate log: ' . $r['errmsg'] . '!'); |
|
97 |
|
exit(1); |
|
98 |
|
} |
|
99 |
|
if ($expect_ff) { |
|
100 |
|
if (!empty($r['data'])) { |
|
101 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
102 |
|
rg_log('We found a merge when a fast-forward was expected!'); |
|
103 |
|
exit(1); |
|
104 |
|
} |
|
105 |
|
} else { |
|
106 |
|
if (!strstr($r['data'], $mm1)) { |
|
107 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
108 |
|
rg_log('Cannot find the expected merge message' |
|
109 |
|
. ' [' . $r['data'] . '] != [' . $mm1 . ']!'); |
|
110 |
|
exit(1); |
|
111 |
|
} |
|
112 |
|
} |
|
113 |
|
rg_log_exit(); |
|
114 |
|
|
|
115 |
|
rg_log_exit(); |
|
116 |
|
} |
File tests/pr_anon.php changed (mode: 100644) (index 2f4fa79..9f80324) |
5 |
5 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
6 |
6 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
7 |
7 |
|
|
|
8 |
|
$test_normal = TRUE; |
|
9 |
|
|
8 |
10 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
9 |
11 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
10 |
12 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
11 |
13 |
require_once($INC . "/user.inc.php"); |
require_once($INC . "/user.inc.php"); |
12 |
14 |
require_once("helpers.inc.php"); |
require_once("helpers.inc.php"); |
13 |
15 |
require_once("http.inc.php"); |
require_once("http.inc.php"); |
|
16 |
|
require_once("mr.inc.php"); |
14 |
17 |
|
|
15 |
18 |
rg_log_set_file("pr_anon.log"); |
rg_log_set_file("pr_anon.log"); |
16 |
19 |
|
|
17 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
18 |
|
$rg_no_db = TRUE; |
|
19 |
20 |
require_once("common.php"); |
require_once("common.php"); |
20 |
21 |
|
|
21 |
22 |
$_testns = 'pr_anon'; |
$_testns = 'pr_anon'; |
|
... |
... |
$rg_event_socket = "/var/lib/rocketgit/sockets/event.sock"; |
25 |
26 |
|
|
26 |
27 |
prepare_http(); |
prepare_http(); |
27 |
28 |
|
|
28 |
|
$ssh = 'ssh -v -o ControlMaster=no -o IdentityFile=../../keys/pr_anon' |
|
29 |
|
. ' -o IdentitiesOnly=yes'; |
|
30 |
|
|
|
31 |
|
rg_log(''); |
|
32 |
|
rg_log_enter('Creating user...'); |
|
33 |
29 |
rg_test_create_user($db, $rg_ui); |
rg_test_create_user($db, $rg_ui); |
34 |
|
rg_log_exit(); |
|
35 |
30 |
|
|
36 |
31 |
|
|
37 |
32 |
rg_log(''); |
rg_log(''); |
|
... |
... |
if ($r === FALSE) { |
44 |
39 |
rg_log_exit(); |
rg_log_exit(); |
45 |
40 |
|
|
46 |
41 |
|
|
47 |
|
rg_log(''); |
|
48 |
|
rg_log_enter('Creating and upload a ssh key...'); |
|
49 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'pr_anon'); |
|
50 |
|
rg_log_exit(); |
|
|
42 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'pr_anon', $kn); |
51 |
43 |
|
|
|
44 |
|
$ssh = 'ssh -o ControlMaster=no -o IdentityFile=../../keys/' . $kn |
|
45 |
|
. ' -o IdentitiesOnly=yes'; |
|
46 |
|
putenv('GIT_SSH_COMMAND=' . $ssh); |
52 |
47 |
|
|
53 |
48 |
rg_log(''); |
rg_log(''); |
54 |
49 |
rg_log_enter('Creating a repo'); |
rg_log_enter('Creating a repo'); |
|
... |
... |
rg_log_exit(); |
60 |
55 |
$url = '/user/' . $rg_ui['username'] . '/' . $repo['name'] . '/mr/'; |
$url = '/user/' . $rg_ui['username'] . '/' . $repo['name'] . '/mr/'; |
61 |
56 |
|
|
62 |
57 |
|
|
63 |
|
// TODO: still needed?! Now, we have it by default. |
|
64 |
|
if (0) { |
|
65 |
|
rg_log(''); |
|
66 |
|
rg_log_enter("Giving anon push rights to any user"); |
|
67 |
|
$x = array(); |
|
68 |
|
$x['right_id'] = 0; |
|
69 |
|
$x['who'] = $rg_ui['uid']; |
|
70 |
|
$x['obj_id'] = $repo['repo_id']; |
|
71 |
|
$x['uid'] = 0; // any user |
|
72 |
|
$x['rights'] = 'FH'; // fetch and anon push |
|
73 |
|
$x['misc'] = ''; // all refs |
|
74 |
|
$x['ip'] = ''; // any IP |
|
75 |
|
$x['prio'] = 100; |
|
76 |
|
$x['description'] = 'bla bla bla'; |
|
77 |
|
$r = rg_rights_set($db, 'repo_refs', $x); |
|
78 |
|
if ($r !== TRUE) { |
|
79 |
|
rg_log("We cannot give rights to the user"); |
|
80 |
|
exit(1); |
|
81 |
|
} |
|
82 |
|
rg_log_exit(); |
|
83 |
|
} |
|
84 |
|
|
|
85 |
|
|
|
86 |
58 |
rg_log(''); |
rg_log(''); |
87 |
59 |
rg_log_enter('Preparing repo...'); |
rg_log_enter('Preparing repo...'); |
88 |
60 |
$r = rg_exec('mkdir -p temp_repos && cd temp_repos' |
$r = rg_exec('mkdir -p temp_repos && cd temp_repos' |
|
... |
... |
rg_log_exit(); |
107 |
79 |
|
|
108 |
80 |
|
|
109 |
81 |
rg_log(''); |
rg_log(''); |
110 |
|
rg_log_enter('Do a non-anonymous push...'); |
|
111 |
|
$r = rg_exec('export GIT_SSH_COMMAND="' . $ssh . '"' |
|
112 |
|
. ' && cd temp_repos/pr_anon' |
|
113 |
|
. ' && echo "change1" > a && git add a && git commit -m "change1 desc"' |
|
114 |
|
. ' && echo "change2" > a && git commit -a -m "change2 desc"' |
|
115 |
|
. ' && git push origin_ssh master', |
|
116 |
|
'', FALSE, FALSE, FALSE); |
|
117 |
|
if ($r['ok'] != 1) { |
|
118 |
|
rg_log('Non-anonymous push was rejected: ' . $r['errmsg'] . '!'); |
|
119 |
|
exit(1); |
|
120 |
|
} |
|
121 |
|
rg_log_exit(); |
|
122 |
|
|
|
123 |
|
|
|
124 |
|
rg_log(''); |
|
125 |
|
rg_log_enter('Do an anonymous push...'); |
|
|
82 |
|
rg_log_enter('Do a merge request against an empty repo...'); |
|
83 |
|
file_put_contents('temp_repos/pr_anon/change0.txt', "change0 desc\n\nthis is the body\nline 2 of body"); |
|
84 |
|
file_put_contents('temp_repos/pr_anon/change1.txt', "change1 desc\n\nthis is the body\nline 2 of body"); |
126 |
85 |
$r = rg_exec('cd temp_repos/pr_anon' |
$r = rg_exec('cd temp_repos/pr_anon' |
127 |
|
. ' && echo "change3" >> a && git add a' |
|
128 |
|
. ' && git commit -m "anon change1 desc"' |
|
129 |
|
. ' && echo "change4" >> a; git commit -a -m "anon change2 desc"' |
|
|
86 |
|
. ' && echo "change0" > a && git add a && git commit -F change0.txt' |
|
87 |
|
. ' && echo "change1" > b && git add b && git commit -F change1.txt' |
130 |
88 |
. ' && git push origin_git master', |
. ' && git push origin_git master', |
131 |
89 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
132 |
90 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
133 |
|
rg_log('Anonymous push was rejected: ' . $r['errmsg'] . '!'); |
|
|
91 |
|
rg_log('Anonymous push request was rejected: ' . $r['errmsg'] . '!'); |
134 |
92 |
exit(1); |
exit(1); |
135 |
93 |
} |
} |
136 |
94 |
rg_log_exit(); |
rg_log_exit(); |
137 |
95 |
|
|
138 |
96 |
|
|
139 |
97 |
rg_log(''); |
rg_log(''); |
140 |
|
rg_log_enter('Check if merge is in db and is against correct branch...'); |
|
141 |
|
$mri = rg_test_mr_in_db($db, $repo['repo_id']); |
|
142 |
|
if (strcmp($mri['refname'], 'refs/heads/master') != 0) { |
|
143 |
|
rg_log_ml('mri: ' . print_r($mri, TRUE)); |
|
144 |
|
rg_log('Seems the ref is not master: ' . $mri['refname'] . '!'); |
|
|
98 |
|
rg_log_enter('Loading the merge request page - to trigger git_merge functions' |
|
99 |
|
. ' with an empty as "old"'); |
|
100 |
|
$data = array(); $headers = array(); |
|
101 |
|
$r = do_req($test_url . $url . '1?t=pr_anon', $data, $headers); |
|
102 |
|
if (!stristr($r['body'], 'This pull request can be merged without conflicts.')) { |
|
103 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
104 |
|
rg_log('Should allow a mr against an empty repo!'); |
145 |
105 |
exit(1); |
exit(1); |
146 |
106 |
} |
} |
147 |
107 |
rg_log_exit(); |
rg_log_exit(); |
148 |
108 |
|
|
149 |
109 |
|
|
150 |
|
rg_log(''); |
|
151 |
|
rg_log_enter('Loading the merge requests page - just to see it appears there'); |
|
152 |
|
$data = array(); |
|
153 |
|
$headers = array(); |
|
154 |
|
$r = do_req($test_url . '/user/' . $rg_ui['username'] |
|
155 |
|
. '/' . $repo['name'] . '/mr?t=pr_anon', $data, $headers); |
|
156 |
|
if (!strstr($r['body'], '>' . $mri['id'] . '<')) { |
|
157 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
158 |
|
rg_log('id link not found!'); |
|
159 |
|
exit(1); |
|
160 |
|
} |
|
161 |
|
rg_log_exit(); |
|
|
110 |
|
test_mr_check($db, $_testns, $rg_ui, $repo, 1, 'refs/heads/master', TRUE); |
162 |
111 |
|
|
163 |
112 |
|
|
164 |
113 |
rg_log(''); |
rg_log(''); |
165 |
|
rg_log_enter('Loading the merge request specific page'); |
|
166 |
|
$data = array(); |
|
167 |
|
$headers = array(); |
|
168 |
|
$r = do_req($test_url . $url . $mri['id'] . '?t=pr_anon', $data, $headers); |
|
169 |
|
if (!strstr($r['body'], 'This pull request can be merged without conflicts')) { |
|
170 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
171 |
|
rg_log('Merge request does not appear as mergeable'); |
|
|
114 |
|
rg_log_enter('Do a non-anonymous push...'); |
|
115 |
|
file_put_contents('temp_repos/pr_anon/change2.txt', "change2 desc\n\nthis is the body\nline 2 of body"); |
|
116 |
|
file_put_contents('temp_repos/pr_anon/change3.txt', "change3 desc\n\nthis is the body\nline 2 of body"); |
|
117 |
|
$r = rg_exec('cd temp_repos/pr_anon' |
|
118 |
|
. ' && echo "change2" > a && git add a && git commit -F change2.txt' |
|
119 |
|
. ' && echo "change3" > a && git commit -a -F change3.txt' |
|
120 |
|
. ' && git push origin_ssh master', |
|
121 |
|
'', FALSE, FALSE, FALSE); |
|
122 |
|
if ($r['ok'] != 1) { |
|
123 |
|
rg_log('Non-anonymous push was rejected: ' . $r['errmsg'] . '!'); |
172 |
124 |
exit(1); |
exit(1); |
173 |
125 |
} |
} |
174 |
126 |
rg_log_exit(); |
rg_log_exit(); |
175 |
127 |
|
|
176 |
128 |
|
|
177 |
129 |
rg_log(''); |
rg_log(''); |
178 |
|
rg_log_enter('Merging merge request...'); |
|
179 |
|
$mm1 = 'This is the merge message <xss>'; |
|
180 |
|
$data = array('token' => $r['tokens']['mr_merge'], |
|
181 |
|
'merge_ff' => 0, 'merge_msg' => $mm1); |
|
182 |
|
$r = do_req($test_url . $url . $mri['id'] . '/merge', $data, $headers); |
|
183 |
|
if ($r === FALSE) { |
|
184 |
|
rg_log('Cannot post merge form'); |
|
185 |
|
exit(1); |
|
186 |
|
} |
|
187 |
|
$tries = 0; |
|
188 |
|
while (1) { |
|
189 |
|
$sql = 'SELECT * FROM merge_requests' |
|
190 |
|
. ' WHERE repo_id = ' . $repo['repo_id'] |
|
191 |
|
. ' AND done > 0 AND id = ' . $mri['id']; |
|
192 |
|
$res = rg_sql_query($db, $sql); |
|
193 |
|
$rows = rg_sql_num_rows($res); |
|
194 |
|
rg_sql_free_result($res); |
|
195 |
|
if ($rows == 1) |
|
196 |
|
break; |
|
197 |
|
|
|
198 |
|
if ($tries == 10) { |
|
199 |
|
rg_log('merge_request was not marked as done in db!'); |
|
200 |
|
exit(1); |
|
201 |
|
} |
|
202 |
|
$tries++; |
|
203 |
|
sleep(1); |
|
204 |
|
} |
|
|
130 |
|
rg_log_enter('Do an anonymous push...'); |
|
131 |
|
putenv('GIT_SSH_COMMAND='); |
|
132 |
|
file_put_contents('temp_repos/pr_anon/change4.txt', "anon change4 desc\n\nthis is the body\nline 2 of body"); |
|
133 |
|
file_put_contents('temp_repos/pr_anon/change5.txt', "anon change5 desc\n\nthis is the body\nline 2 of body"); |
205 |
134 |
$r = rg_exec('cd temp_repos/pr_anon' |
$r = rg_exec('cd temp_repos/pr_anon' |
206 |
|
. ' && git pull origin_git master' |
|
207 |
|
. ' && git log --oneline -n1', |
|
|
135 |
|
. ' && echo "change4" >> a && git add a' |
|
136 |
|
. ' && git commit -F change4.txt' |
|
137 |
|
. ' && echo "change5" >> a; git commit -a -F change5.txt' |
|
138 |
|
. ' && git push origin_git master', |
208 |
139 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
209 |
140 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
210 |
|
rg_log('Could not pull: ' . $r['errmsg'] . '!'); |
|
211 |
|
exit(1); |
|
212 |
|
} |
|
213 |
|
if (!strstr($r['data'], $mm1)) { |
|
214 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
215 |
|
rg_log('Cannot find the merge message!'); |
|
|
141 |
|
rg_log('Anonymous push was rejected: ' . $r['errmsg'] . '!'); |
216 |
142 |
exit(1); |
exit(1); |
217 |
143 |
} |
} |
218 |
144 |
rg_log_exit(); |
rg_log_exit(); |
219 |
145 |
|
|
220 |
146 |
|
|
|
147 |
|
test_mr_check($db, $_testns, $rg_ui, $repo, 2, 'refs/heads/master', FALSE); |
|
148 |
|
|
|
149 |
|
|
221 |
150 |
rg_log(''); |
rg_log(''); |
222 |
151 |
rg_log_enter('Now, try to see what happens when a merge is with conflicts...'); |
rg_log_enter('Now, try to see what happens when a merge is with conflicts...'); |
223 |
152 |
$r = rg_exec('cd temp_repos/pr_anon' |
$r = rg_exec('cd temp_repos/pr_anon' |
|
... |
... |
$r = rg_exec('cd temp_repos/pr_anon' |
226 |
155 |
. ' && git push origin_git master', |
. ' && git push origin_git master', |
227 |
156 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
228 |
157 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
|
158 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
229 |
159 |
rg_log('Could not pull/commit/push by git proto: ' . $r['errmsg'] . '!'); |
rg_log('Could not pull/commit/push by git proto: ' . $r['errmsg'] . '!'); |
230 |
160 |
exit(1); |
exit(1); |
231 |
161 |
} |
} |
232 |
|
$r = rg_exec('export GIT_SSH_COMMAND="' . $ssh . '"' |
|
233 |
|
. ' && cd temp_repos/pr_anon' |
|
|
162 |
|
putenv('GIT_SSH_COMMAND=' . $ssh); |
|
163 |
|
$r = rg_exec('cd temp_repos/pr_anon' |
234 |
164 |
. ' && git reset --hard HEAD^1' |
. ' && git reset --hard HEAD^1' |
235 |
165 |
. ' && echo "change1" > a' |
. ' && echo "change1" > a' |
236 |
|
. ' && git commit -a -m "conflict1a"' |
|
237 |
|
. ' && git push origin_ssh master', |
|
|
166 |
|
. ' && echo "commit" && git commit -a -m "conflict1a"' |
|
167 |
|
. ' && echo "push" && strace -s200 -f -tt -o pr_anon.strace git push origin_ssh master', |
238 |
168 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
239 |
169 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
|
170 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
240 |
171 |
rg_log('Could not reset/commit/push by ssh proto: ' . $r['errmsg'] . '!'); |
rg_log('Could not reset/commit/push by ssh proto: ' . $r['errmsg'] . '!'); |
241 |
172 |
exit(1); |
exit(1); |
242 |
173 |
} |
} |
243 |
|
$mri = rg_test_mr_in_db($db, $repo['repo_id']); |
|
|
174 |
|
$mri = rg_test_mr_info($db, $repo['repo_id'], 3); |
244 |
175 |
$data = array(); |
$data = array(); |
245 |
176 |
$headers = array(); |
$headers = array(); |
246 |
177 |
$r = do_req($test_url . $url . $mri['id'] . '?t=pr_anon', $data, $headers); |
$r = do_req($test_url . $url . $mri['id'] . '?t=pr_anon', $data, $headers); |
247 |
|
if (!strstr($r['body'], 'This pull request cannot be merged without conflicts')) { |
|
|
178 |
|
if (!strstr($r['body'], 'This merge request cannot be merged without conflicts')) { |
248 |
179 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
249 |
|
rg_log('Pull request does not appear as non-mergeable'); |
|
|
180 |
|
rg_log('Merge request appears as mergeable and should not!'); |
250 |
181 |
exit(1); |
exit(1); |
251 |
182 |
} |
} |
252 |
183 |
rg_log_exit(); |
rg_log_exit(); |
File tests/wh_cloud.php changed (mode: 100644) (index 060a241..a647b74) |
2 |
2 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
|
5 |
|
$test_normal = TRUE; |
|
6 |
|
|
5 |
7 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
8 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
7 |
9 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
|
... |
... |
require_once("http.inc.php"); |
11 |
13 |
|
|
12 |
14 |
rg_log_set_file("wh_cloud.log"); |
rg_log_set_file("wh_cloud.log"); |
13 |
15 |
|
|
14 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
15 |
|
$rg_no_db = TRUE; |
|
16 |
16 |
require_once("common.php"); |
require_once("common.php"); |
17 |
17 |
|
|
18 |
18 |
$_testns = 'wh_cloud'; |
$_testns = 'wh_cloud'; |
|
... |
... |
rg_log_exit(); |
72 |
72 |
|
|
73 |
73 |
rg_log(''); |
rg_log(''); |
74 |
74 |
rg_log_enter('Finding out the hook id...'); |
rg_log_enter('Finding out the hook id...'); |
75 |
|
for ($i = 0; $i < 10; $i++) { |
|
76 |
|
$r = rg_cache_get('wh' . '::' . $rg_ui['uid']); |
|
77 |
|
if ($r !== FALSE) |
|
78 |
|
break; |
|
79 |
|
sleep(1); |
|
80 |
|
} |
|
81 |
|
if ($r === FALSE) { |
|
82 |
|
rg_log('Cannot get id from cache'); |
|
83 |
|
exit(1); |
|
84 |
|
} |
|
|
75 |
|
$r = test_wait_cache('wh' . '::' . $rg_ui['uid']); |
85 |
76 |
rg_log_ml('r=' . print_r($r, TRUE)); |
rg_log_ml('r=' . print_r($r, TRUE)); |
86 |
77 |
$t = array_keys($r['list']); |
$t = array_keys($r['list']); |
87 |
78 |
if (count($t) != 1) { |
if (count($t) != 1) { |
|
... |
... |
rg_log('wh_id=' . $wh_id); |
93 |
84 |
rg_log_exit(); |
rg_log_exit(); |
94 |
85 |
|
|
95 |
86 |
|
|
96 |
|
rg_log(''); |
|
97 |
|
rg_log_enter('Creating and upload a ssh key...'); |
|
98 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'wh_cloud'); |
|
99 |
|
rg_log_exit(); |
|
|
87 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'wh_cloud', $kn); |
100 |
88 |
|
|
101 |
89 |
|
|
102 |
90 |
rg_log(''); |
rg_log(''); |
|
... |
... |
rg_log_exit(); |
117 |
105 |
|
|
118 |
106 |
rg_log(''); |
rg_log(''); |
119 |
107 |
rg_log_enter('Testing if hook executed with success'); |
rg_log_enter('Testing if hook executed with success'); |
120 |
|
for ($i = 0; $i < 10; $i++) { |
|
121 |
|
$key = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $wh_id; |
|
122 |
|
$r = rg_cache_get($key); |
|
123 |
|
rg_log_ml('cache: ' . $r); |
|
124 |
|
if ($r !== FALSE) |
|
125 |
|
break; |
|
126 |
|
sleep(1); |
|
127 |
|
} |
|
128 |
|
if ($r === FALSE) { |
|
129 |
|
rg_log('Seems the event did not set the cache!'); |
|
130 |
|
exit(1); |
|
131 |
|
} |
|
|
108 |
|
$key = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $wh_id; |
|
109 |
|
$r = test_wait_cache($key); |
132 |
110 |
if (!strstr($r, '"deploymentId":"d-') && !strstr($r, 'is already deploying')) { |
if (!strstr($r, '"deploymentId":"d-') && !strstr($r, 'is already deploying')) { |
133 |
111 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
134 |
112 |
rg_log('Seems hook did not executed correctly!'); |
rg_log('Seems hook did not executed correctly!'); |
File tests/wh_http.php changed (mode: 100644) (index 3c1a62d..24874a7) |
2 |
2 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
|
5 |
|
$test_normal = TRUE; |
|
6 |
|
|
5 |
7 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
8 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
7 |
9 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
|
... |
... |
require_once("http.inc.php"); |
11 |
13 |
|
|
12 |
14 |
rg_log_set_file("wh_http.log"); |
rg_log_set_file("wh_http.log"); |
13 |
15 |
|
|
14 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
15 |
|
$rg_no_db = TRUE; |
|
16 |
16 |
require_once("common.php"); |
require_once("common.php"); |
17 |
17 |
|
|
18 |
18 |
$_testns = 'wh_http'; |
$_testns = 'wh_http'; |
|
... |
... |
rg_log('port1=' . $port1 . ' port2=' . $port2 . ' port3=' . $port3); |
27 |
27 |
|
|
28 |
28 |
function clean() |
function clean() |
29 |
29 |
{ |
{ |
30 |
|
rg_log_enter('clean'); |
|
31 |
|
for ($id = 1; $id <= 3; $id++) { |
|
|
30 |
|
rg_log_set_file("wh_http_clean.log"); |
|
31 |
|
for ($id = 1; $id <= 3; $id++) |
32 |
32 |
rg_exec('fuser -k -9 wh-stunnel-' . $id . '.log', '', FALSE, FALSE, FALSE); |
rg_exec('fuser -k -9 wh-stunnel-' . $id . '.log', '', FALSE, FALSE, FALSE); |
33 |
|
@unlink('wh-stunnel.conf-' . $id . '.tmp'); |
|
34 |
|
} |
|
35 |
|
rg_log_exit(); |
|
36 |
33 |
} |
} |
37 |
34 |
|
|
38 |
35 |
prepare_http(); |
prepare_http(); |
|
... |
... |
if ($pid == -1) { |
82 |
79 |
exit(1); |
exit(1); |
83 |
80 |
} |
} |
84 |
81 |
if ($pid == 0) { //child |
if ($pid == 0) { //child |
|
82 |
|
rg_log_set_file('wh-stunnel-1-rg.log'); |
85 |
83 |
rg_exec('stunnel wh-stunnel.conf-1.tmp 1>wh-stunnel-1-1.log 2>wh-stunnel-1-2.log', |
rg_exec('stunnel wh-stunnel.conf-1.tmp 1>wh-stunnel-1-1.log 2>wh-stunnel-1-2.log', |
86 |
84 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
87 |
85 |
exit(0); |
exit(0); |
|
... |
... |
if ($pid == -1) { |
97 |
95 |
exit(1); |
exit(1); |
98 |
96 |
} |
} |
99 |
97 |
if ($pid == 0) { //child |
if ($pid == 0) { //child |
|
98 |
|
rg_log_set_file('wh-stunnel-2-rg.log'); |
100 |
99 |
rg_exec('stunnel wh-stunnel.conf-2.tmp 1>wh-stunnel-2-1.log 2>wh-stunnel-2-2.log', |
rg_exec('stunnel wh-stunnel.conf-2.tmp 1>wh-stunnel-2-1.log 2>wh-stunnel-2-2.log', |
101 |
100 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
102 |
101 |
exit(0); |
exit(0); |
|
... |
... |
if ($pid == -1) { |
112 |
111 |
exit(1); |
exit(1); |
113 |
112 |
} |
} |
114 |
113 |
if ($pid == 0) { //child |
if ($pid == 0) { //child |
|
114 |
|
rg_log_set_file('wh-stunnel-3-rg.log'); |
115 |
115 |
rg_exec('stunnel wh-stunnel.conf-3.tmp 1>wh-stunnel-3-1.log 2>wh-stunnel-3-2.log', |
rg_exec('stunnel wh-stunnel.conf-3.tmp 1>wh-stunnel-3-1.log 2>wh-stunnel-3-2.log', |
116 |
116 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
117 |
117 |
exit(0); |
exit(0); |
|
... |
... |
rg_test_wh_add_edit($db, $rg_ui, 'http', $extra); |
200 |
200 |
|
|
201 |
201 |
|
|
202 |
202 |
rg_log('Finding out the ids...'); |
rg_log('Finding out the ids...'); |
203 |
|
for ($i = 0; $i < 10; $i++) { |
|
204 |
|
$r = rg_cache_get('wh' . '::' . $rg_ui['uid']); |
|
205 |
|
if ($r !== FALSE) |
|
206 |
|
break; |
|
207 |
|
sleep(1); |
|
208 |
|
} |
|
209 |
|
if ($r === FALSE) { |
|
210 |
|
rg_log('Cannot get id from cache'); |
|
211 |
|
exit(1); |
|
212 |
|
} |
|
|
203 |
|
$r = test_wait_cache('wh' . '::' . $rg_ui['uid']); |
213 |
204 |
rg_log_ml('r=' . print_r($r, TRUE)); |
rg_log_ml('r=' . print_r($r, TRUE)); |
214 |
205 |
$t = array_keys($r['list']); |
$t = array_keys($r['list']); |
215 |
206 |
if (count($t) != 3) { |
if (count($t) != 3) { |
|
... |
... |
rg_test_create_repo($db, $rg_ui, $repo); |
231 |
222 |
|
|
232 |
223 |
|
|
233 |
224 |
rg_log(''); |
rg_log(''); |
234 |
|
rg_log('Testing if the curl posted with success (wh1) (should not work)'); |
|
235 |
|
for ($i = 0; $i < 10; $i++) { |
|
236 |
|
$r = rg_cache_get($key1 . '::' . $wh_id1); |
|
237 |
|
rg_log_ml('cache: ' . $r); |
|
238 |
|
if ($r !== FALSE) |
|
239 |
|
break; |
|
240 |
|
sleep(1); |
|
241 |
|
} |
|
242 |
|
if ($r === FALSE) { |
|
243 |
|
rg_log('Seems the event does not set the cache!'); |
|
244 |
|
exit(1); |
|
245 |
|
} |
|
|
225 |
|
rg_log_enter('Testing if the curl posted with success (wh1) (should not work)'); |
|
226 |
|
$r = test_wait_cache($key1 . '::' . $wh_id1); |
246 |
227 |
if (strcmp($r, "BAD") != 0) { |
if (strcmp($r, "BAD") != 0) { |
247 |
228 |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id1 . '::last_output'; |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id1 . '::last_output'; |
248 |
|
$_e = rg_cache_get($_k); |
|
|
229 |
|
$_e = test_wait_cache($_k); |
|
230 |
|
rg_log_ml('_e:' . $_e); |
249 |
231 |
rg_log('Seems wh1 executed correctly without client' |
rg_log('Seems wh1 executed correctly without client' |
250 |
232 |
. ' cert (r=' . $r . ')!'); |
. ' cert (r=' . $r . ')!'); |
251 |
|
rg_log_ml($_e); |
|
252 |
233 |
exit(1); |
exit(1); |
253 |
234 |
} |
} |
|
235 |
|
rg_log_exit(); |
254 |
236 |
|
|
255 |
237 |
|
|
256 |
238 |
rg_log(''); |
rg_log(''); |
257 |
|
rg_log('Testing if the curl posted with success (wh2) (should work)'); |
|
258 |
|
for ($i = 0; $i < 10; $i++) { |
|
259 |
|
$r = rg_cache_get($key2 . '::' . $wh_id2); |
|
260 |
|
rg_log_ml('cache: ' . print_r($r, TRUE)); |
|
261 |
|
if ($r !== FALSE) |
|
262 |
|
break; |
|
263 |
|
sleep(1); |
|
264 |
|
} |
|
|
239 |
|
rg_log_enter('Testing if the curl posted with success (wh2) (should work)'); |
|
240 |
|
$r = test_wait_cache($key2 . '::' . $wh_id2); |
265 |
241 |
if (strcmp($r, "OK") != 0) { |
if (strcmp($r, "OK") != 0) { |
266 |
242 |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id2 . '::last_output'; |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id2 . '::last_output'; |
267 |
|
$_e = rg_cache_get($_k); |
|
|
243 |
|
$_e = test_wait_cache($_k); |
|
244 |
|
rg_log_ml('_e:' . $_e); |
268 |
245 |
rg_log('Seems wh2 did not returned success' |
rg_log('Seems wh2 did not returned success' |
269 |
246 |
. ' (r=' . $r . ')!'); |
. ' (r=' . $r . ')!'); |
270 |
|
rg_log_ml($_e); |
|
271 |
247 |
exit(1); |
exit(1); |
272 |
248 |
} |
} |
|
249 |
|
rg_log_exit(); |
273 |
250 |
|
|
274 |
251 |
|
|
275 |
252 |
rg_log(''); |
rg_log(''); |
276 |
|
rg_log('Testing if the curl posted with success (wh3) (should work)'); |
|
277 |
|
for ($i = 0; $i < 10; $i++) { |
|
278 |
|
$r = rg_cache_get($key3 . '::' . $wh_id3); |
|
279 |
|
rg_log_ml('cache: ' . print_r($r, TRUE)); |
|
280 |
|
if ($r !== FALSE) |
|
281 |
|
break; |
|
282 |
|
sleep(1); |
|
283 |
|
} |
|
|
253 |
|
rg_log_enter('Testing if the curl posted with success (wh3) (should work)'); |
|
254 |
|
$r = test_wait_cache($key3 . '::' . $wh_id3); |
284 |
255 |
if (strcmp($r, "OK") != 0) { |
if (strcmp($r, "OK") != 0) { |
285 |
256 |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id3 . '::last_output'; |
$_k = 'wh::' . $rg_ui['uid'] . '::list::' . $wh_id3 . '::last_output'; |
286 |
|
$_e = rg_cache_get($_k); |
|
|
257 |
|
$_e = test_wait_cache($_k); |
|
258 |
|
rg_log_ml('_e:' . $_e); |
287 |
259 |
rg_log('Seems wh3 did not returned success' |
rg_log('Seems wh3 did not returned success' |
288 |
260 |
. ' (r=' . $r . ')!'); |
. ' (r=' . $r . ')!'); |
289 |
|
rg_log_ml($_e); |
|
290 |
261 |
exit(1); |
exit(1); |
291 |
262 |
} |
} |
|
263 |
|
rg_log_exit(); |
292 |
264 |
|
|
293 |
265 |
|
|
294 |
266 |
rg_log(''); |
rg_log(''); |
295 |
|
rg_log('Testing the edit of webhook1...'); |
|
|
267 |
|
rg_log_enter('Testing the edit of webhook1...'); |
296 |
268 |
$extra = array( |
$extra = array( |
297 |
269 |
'wh::id' => $wh_id1, |
'wh::id' => $wh_id1, |
298 |
270 |
'wh::htype' => 'http', |
'wh::htype' => 'http', |
|
... |
... |
$row = rg_sql_fetch_array($res); |
321 |
293 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
322 |
294 |
$row['idata'] = unserialize($row['idata']); |
$row['idata'] = unserialize($row['idata']); |
323 |
295 |
$key = 'wh' . '::' . $rg_ui['uid'] . '::' . 'list' . '::' . $wh_id1; |
$key = 'wh' . '::' . $rg_ui['uid'] . '::' . 'list' . '::' . $wh_id1; |
324 |
|
rg_cache_core_unset($key); // else we will get previous copy! |
|
325 |
|
$c = rg_cache_get($key); |
|
|
296 |
|
$c = test_wait_cache($key); |
326 |
297 |
$list = array('htype' => 'http', 'events' => 'CB', 'repo' => '.*', |
$list = array('htype' => 'http', 'events' => 'CB', 'repo' => '.*', |
327 |
298 |
'refname' => '..*', |
'refname' => '..*', |
328 |
299 |
'description' => 'desc2 <xss>', 'key' => 'another key <xss>', |
'description' => 'desc2 <xss>', 'key' => 'another key <xss>', |
|
... |
... |
foreach ($list as $k => $v) { |
355 |
326 |
exit(1); |
exit(1); |
356 |
327 |
} |
} |
357 |
328 |
} |
} |
|
329 |
|
rg_log_exit(); |
358 |
330 |
|
|
359 |
331 |
|
|
360 |
332 |
rg_log(''); |
rg_log(''); |
File tests/wh_lambda.php changed (mode: 100644) (index 4e7016e..f164a5e) |
2 |
2 |
error_reporting(E_ALL | E_STRICT); |
error_reporting(E_ALL | E_STRICT); |
3 |
3 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
|
5 |
|
$test_normal = TRUE; |
|
6 |
|
|
5 |
7 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
8 |
require_once(dirname(__FILE__) . "/config.php"); |
require_once(dirname(__FILE__) . "/config.php"); |
7 |
9 |
require_once($INC . "/init.inc.php"); |
require_once($INC . "/init.inc.php"); |
|
... |
... |
require_once("http.inc.php"); |
11 |
13 |
|
|
12 |
14 |
rg_log_set_file("wh_lambda.log"); |
rg_log_set_file("wh_lambda.log"); |
13 |
15 |
|
|
14 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
15 |
|
$rg_no_db = TRUE; |
|
16 |
16 |
require_once("common.php"); |
require_once("common.php"); |
17 |
17 |
|
|
18 |
18 |
$_testns = 'wh_lambda'; |
$_testns = 'wh_lambda'; |
19 |
19 |
$rg_cache_enable = TRUE; |
$rg_cache_enable = TRUE; |
20 |
20 |
$rg_cache_debug = TRUE; |
$rg_cache_debug = TRUE; |
21 |
|
$rg_event_socket = "/var/lib/rocketgit/sockets/event.sock"; |
|
22 |
21 |
|
|
23 |
22 |
prepare_http(); |
prepare_http(); |
24 |
23 |
|
|
|
... |
... |
rg_log_exit(); |
72 |
71 |
|
|
73 |
72 |
rg_log(''); |
rg_log(''); |
74 |
73 |
rg_log_enter('Finding out the hook id...'); |
rg_log_enter('Finding out the hook id...'); |
75 |
|
for ($i = 0; $i < 10; $i++) { |
|
76 |
|
$r = rg_cache_get('wh' . '::' . $rg_ui['uid']); |
|
77 |
|
if ($r !== FALSE) |
|
78 |
|
break; |
|
79 |
|
sleep(1); |
|
80 |
|
} |
|
81 |
|
if ($r === FALSE) { |
|
82 |
|
rg_log('Cannot get id from cache'); |
|
83 |
|
exit(1); |
|
84 |
|
} |
|
|
74 |
|
$r = test_wait_cache('wh' . '::' . $rg_ui['uid']); |
85 |
75 |
rg_log_ml('r=' . print_r($r, TRUE)); |
rg_log_ml('r=' . print_r($r, TRUE)); |
86 |
76 |
$t = array_keys($r['list']); |
$t = array_keys($r['list']); |
87 |
77 |
if (count($t) != 1) { |
if (count($t) != 1) { |
|
... |
... |
rg_log('wh_id=' . $wh_id); |
93 |
83 |
rg_log_exit(); |
rg_log_exit(); |
94 |
84 |
|
|
95 |
85 |
|
|
96 |
|
rg_log(''); |
|
97 |
|
rg_log_enter('Creating and upload a ssh key...'); |
|
98 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'wh_cloud'); |
|
99 |
|
rg_log_exit(); |
|
|
86 |
|
rg_test_upload_ssh_key($db, $rg_ui, 'wh_cloud', $kn); |
100 |
87 |
|
|
101 |
88 |
|
|
102 |
89 |
rg_log(''); |
rg_log(''); |
|
... |
... |
rg_log_enter('Pushing repo, so the trigger has a chanse to execute...'); |
105 |
92 |
$repo_url = 'ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port |
$repo_url = 'ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port |
106 |
93 |
. '/user/' . $rg_ui['username'] . '/' . $repo['name']; |
. '/user/' . $rg_ui['username'] . '/' . $repo['name']; |
107 |
94 |
rg_log('repo_url=' . $repo_url); |
rg_log('repo_url=' . $repo_url); |
108 |
|
$r = rg_exec('./wh_cloud.git.sh ' . escapeshellarg($repo_url), '', FALSE, FALSE, FALSE); |
|
|
95 |
|
$r = rg_exec('./wh_cloud.git.sh ' . escapeshellarg($repo_url), |
|
96 |
|
'', FALSE, FALSE, FALSE); |
109 |
97 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
110 |
98 |
rg_log_ml('Could not create local git repo: ' . $r['errmsg'] . '!'); |
rg_log_ml('Could not create local git repo: ' . $r['errmsg'] . '!'); |
111 |
99 |
exit(1); |
exit(1); |
|
... |
... |
rg_log_exit(); |
115 |
103 |
|
|
116 |
104 |
rg_log(''); |
rg_log(''); |
117 |
105 |
rg_log_enter('Testing if hook executed with success'); |
rg_log_enter('Testing if hook executed with success'); |
118 |
|
for ($i = 0; $i < 10; $i++) { |
|
119 |
|
$key = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $wh_id; |
|
120 |
|
$r = rg_cache_get($key); |
|
121 |
|
rg_log_ml('cache: ' . $r); |
|
122 |
|
if ($r !== FALSE) |
|
123 |
|
break; |
|
124 |
|
sleep(1); |
|
125 |
|
} |
|
126 |
|
if ($r === FALSE) { |
|
127 |
|
rg_log('Seems the event did not set the cache!'); |
|
128 |
|
exit(1); |
|
129 |
|
} |
|
|
106 |
|
$key = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $wh_id; |
|
107 |
|
$r = test_wait_cache($key); |
130 |
108 |
if (strcmp($r, '"Hello from Lambda; key: aaa branch=master repo=wh-cloud"') != 0) { |
if (strcmp($r, '"Hello from Lambda; key: aaa branch=master repo=wh-cloud"') != 0) { |
131 |
109 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
132 |
110 |
rg_log('Seems hook did not executed correctly!'); |
rg_log('Seems hook did not executed correctly!'); |