List of commits:
Subject Hash Author Date (UTC)
Lots of tests updates 183c4af52e56ae4e4fd74a35e2b17ac79952aec6 Catalin(ux) M. BOIE 2020-03-20 16:10:33
Improved a little bit the mail reporting for admin 576f96d554b1e273391ac54404bf5f885325e5e8 Catalin(ux) M. BOIE 2020-03-03 19:25:17
Worker and builder big changes 90f596e4fd8fa291b1da831bce609b486c7a5875 Catalin(ux) M. BOIE 2020-01-06 13:31:20
Samples update (switch to systemd services for builder and worker) 8bfde1fb79778d024350bf5d75f076fb5e178512 Catalin(ux) M. BOIE 2020-01-06 12:50:21
builder: show queue in the web page 6cab7820b0bd2622afb77391a9e9515e0e837eef Catalin(ux) M. BOIE 2020-01-06 12:49:26
totp: Allow also years for 'val' command d666df0cec948f938469b9eb12a1b981cb41cfa1 Catalin(ux) M. BOIE 2020-01-04 14:39:33
worker: change git clone parameters because we could not clone 8eb2727ac17e12e148f39c72e1f4bd1e31319b33 Catalin(ux) M. BOIE 2019-12-19 03:34:26
Added a TODO for worker 492fb4546829f53adacd74c4647c3634f7c37065 Catalin(ux) M. BOIE 2019-12-18 22:23:12
worker improvements 4387b00291b5848aa08c303f9d62a126a6806a35 Catalin(ux) M. BOIE 2019-12-18 22:17:23
.spec: require tidy for building the tests c0deab2ce24388c91d2bc2e96338a260c9657dd6 Catalin(ux) M. BOIE 2019-12-18 22:15:29
nginx configuration update 015c9404229f2ff7fb91cc57ab21289f01878334 Catalin(ux) M. BOIE 2019-12-18 21:55:13
Added Business model to comparison c62d466580aca0ff3371f3ba369959c7ef7631d0 Catalin(ux) M. BOIE 2019-11-21 20:44:16
CSS small correction ded9ef6bce5bebfa815bc7ae5733bc8e0810af3b Catalin(ux) M. BOIE 2019-11-21 18:20:41
Added LDAP/qrencode to features/thanks pages d269d59787f61045f5831c6985899c28da08ebeb Catalin(ux) M. BOIE 2019-11-21 18:20:22
Invalidate slave table cache when updating the db structure, else new slaves will not be created 8e1bf7feeb87818179e7152a356e0f408da706f2 Catalin(ux) M. BOIE 2019-11-19 19:33:15
docker: push also the latest label a72e2e74355d772ae45bb99798ad47082390943c Catalin(ux) M. BOIE 2019-11-19 19:32:11
More statistics changes (load, cpu, mem) e7f38e72405a227788a7011ea17dd57d0d4de67c Catalin(ux) M. BOIE 2019-11-19 19:31:24
Cosmetic 0a0b258e8993cb5035e018b049018ac41b99eb01 Catalin(ux) M. BOIE 2019-11-17 11:09:56
Insist on respecting the privacy b464bcc35476ffa23a83beaf956e8f7b15163d7c Catalin(ux) M. BOIE 2019-11-17 11:03:36
Remove PayPal donation because of legal uncertainly cd938af4c5cdbd81190e535973588dee6b697d34 Catalin(ux) M. BOIE 2019-11-17 11:03:07
Commit 183c4af52e56ae4e4fd74a35e2b17ac79952aec6 - Lots of tests updates
Author: Catalin(ux) M. BOIE
Author date (UTC): 2020-03-20 16:10
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2020-03-20 16:10
Parent(s): 576f96d554b1e273391ac54404bf5f885325e5e8
Signing key:
Tree: 5f583016ab7ba2d882ab62b73442465004b2a471
File Lines added Lines deleted
root/themes/default/repo/err/file_too_big.html 0 0
root/themes/default/repo/err/invalid.html 0 0
root/themes/default/repo/err/no_git_dir.html 0 0
root/themes/default/repo/err/not_init.html 0 0
tests/_run_tests.sh 2 0
tests/admin_set_git.php 1 2
tests/admin_set_web.php 1 2
tests/api.sh 3 1
tests/bug.php 3 0
tests/by_http.php 1 2
tests/common.php 2 0
tests/config.php 19 2
tests/email.php 4 30
tests/env.txt 5 0
tests/export.php 2 2
tests/git.php 2 2
tests/git2.php 33 17
tests/git2.sh 4 0
tests/git_big_push.php 2 2
tests/git_log1.expected 0 20
tests/helpers.inc.php 59 22
tests/hook_update.sh 24 18
tests/hook_update_help.php 1 1
tests/http_admin.php 2 2
tests/http_bug.php 2 2
tests/http_confirm.php 3 15
tests/http_create_account.php 2 2
tests/http_csrf.php 1 2
tests/http_forgot.php 5 11
tests/http_keys.php 1 2
tests/http_login.php 2 2
tests/http_settings.php 26 14
tests/http_top.php 2 3
tests/http_totp.php 2 2
tests/ldap.php 2 4
tests/ldap_core.php 1 2
tests/mr.inc.php 116 0
tests/pr_anon.php 52 121
tests/repo.php 1 1
tests/source.php 4 7
tests/sql-fork.php 1 2
tests/ssh.php 3 3
tests/util.php 32 4
tests/wh-helper.sh 16 1
tests/wh-stunnel.conf 2 1
tests/wh_cloud.git.sh 1 1
tests/wh_cloud.php 6 28
tests/wh_http.php 26 54
tests/wh_lambda.php 8 30
File root/themes/default/repo/err/file_too_big.html renamed from root/themes/default/repo/file_too_big.html (similarity 100%)
File root/themes/default/repo/err/invalid.html renamed from root/themes/default/repo/invalid.html (similarity 100%)
File root/themes/default/repo/err/no_git_dir.html renamed from root/themes/default/repo/no_git_dir.html (similarity 100%)
File root/themes/default/repo/err/not_init.html renamed from root/themes/default/repo/not_init.html (similarity 100%)
File tests/_run_tests.sh changed (mode: 100755) (index f60da2f..42e2ef7)
1 1 #!/bin/bash #!/bin/bash
2 2
3 . ./env.txt
4
3 5 tests="ldap_core ldap \ tests="ldap_core ldap \
4 6 admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \ admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \
5 7 http_forgot \ http_forgot \
File tests/admin_set_git.php changed (mode: 100644) (index 0b1384c..46abec4)
... ... 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('admin_set_git.log'); rg_log_set_file('admin_set_git.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 = 'admin_set_git'; $_testns = 'admin_set_git';
File tests/admin_set_web.php changed (mode: 100644) (index 8c73afd..5fd4bc2)
... ... 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('admin_set_web.log'); rg_log_set_file('admin_set_web.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 = 'admin_set_web'; $_testns = 'admin_set_web';
File tests/api.sh changed (mode: 100755) (index 8fa9b2c..076d158)
1 1 #!/bin/bash #!/bin/bash
2 2
3 . ./env.txt
4
3 5 user="catab" user="catab"
4 6 key="925cb5896280c6f132263336a5e90819" key="925cb5896280c6f132263336a5e90819"
5 7 curl --silent --header "Authorization: ${user} ${key}" \ curl --silent --header "Authorization: ${user} ${key}" \
6 8 --data "{\"cmd\": \"user_info\", \"user\": \"${user}\"}" \ --data "{\"cmd\": \"user_info\", \"user\": \"${user}\"}" \
7 9 -o api.out \ -o api.out \
8 http://rg:9000/op/api
10 http://rg.embedromix.ro:9002/op/api
9 11 json_verify < api.out > /dev/null json_verify < api.out > /dev/null
10 12 if [ "${?}" != "0" ]; then if [ "${?}" != "0" ]; then
11 13 echo "JSON seems to not be ok!" echo "JSON seems to not be ok!"
File tests/bug.php changed (mode: 100644) (index 5f388b7..b2ac4e2)
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 $rg_cache_debug = TRUE;
7
5 8 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
6 9 require_once(dirname(__FILE__) . "/config.php"); require_once(dirname(__FILE__) . "/config.php");
7 10 require_once($INC . "/init.inc.php"); require_once($INC . "/init.inc.php");
File tests/by_http.php changed (mode: 100644) (index 12fdd6c..a597a23)
... ... ini_set("track_errors", "On");
5 5 $rg_cache_debug = FALSE; $rg_cache_debug = FALSE;
6 6 $rg_util_debug = FALSE; $rg_util_debug = FALSE;
7 7 $rg_sql_debug = 100; $rg_sql_debug = 100;
8 $test_normal = TRUE;
8 9
9 10 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
10 11 require_once(dirname(__FILE__) . "/config.php"); require_once(dirname(__FILE__) . "/config.php");
 
... ... require_once("http.inc.php");
15 16
16 17 rg_log_set_file("by_http.log"); rg_log_set_file("by_http.log");
17 18
18 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10";
19 $rg_no_db = TRUE;
20 19 require_once("common.php"); require_once("common.php");
21 20
22 21 $_testns = 'by_http'; $_testns = 'by_http';
File tests/common.php changed (mode: 100644) (index c27a36e..a19e497)
... ... require_once($INC . "/fixes.inc.php");
7 7
8 8 $rg_util_debug = TRUE; $rg_util_debug = TRUE;
9 9
10 rg_log('rg_event_socket: ' . $rg_event_socket);
11
10 12 rg_sql_app("rg-tests"); rg_sql_app("rg-tests");
11 13 $db = rg_sql_open($rg_sql); $db = rg_sql_open($rg_sql);
12 14 if ($db === FALSE) { if ($db === FALSE) {
File tests/config.php changed (mode: 100644) (index 6bfc906..dec64ef)
... ... $rg_theme_dir = $rg_base . "/themes";
27 27 $rg_theme = "util"; $rg_theme = "util";
28 28 $rg_lang = "en"; $rg_lang = "en";
29 29 $rg_cache_enable = FALSE; $rg_cache_enable = FALSE;
30 $rg_event_socket = "";
30 $rg_event_socket = '';
31 31 $rg_ssh_host = 'rg.embedromix.ro'; $rg_ssh_host = 'rg.embedromix.ro';
32 32 $rg_ssh_port = 2222; $rg_ssh_port = 2222;
33 33 $rg_git_host = 'localhost'; $rg_git_host = 'localhost';
 
... ... $rg_git_port = 9418;
36 36 // For http testing // For http testing
37 37 //$test_url = "http://rg.embedromix.ro:9000"; // apache //$test_url = "http://rg.embedromix.ro:9000"; // apache
38 38 $test_url = "http://rg.embedromix.ro:9002"; // nginx $test_url = "http://rg.embedromix.ro:9002"; // nginx
39 //$test_url = "https://rg.embedromix.ro:9003"; // nginx TLS
39 40 $rg_debug = 1; $rg_debug = 1;
40 41
41 42 $rg_base_url = $test_url; $rg_base_url = $test_url;
42 43
43 ?>
44 $a = @file(__DIR__ . '/env.txt');
45 foreach ($a as $line) {
46 if (strncmp($line, '#', 1) == 0)
47 continue;
48
49 putenv($line);
50 }
51
52 if (!isset($test_normal))
53 $test_normal = FALSE;
54
55 if ($test_normal) {
56 $rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10';
57 $rg_event_socket = '/var/lib/rocketgit/sockets/event.sock';
58 $rg_no_db = TRUE;
59 $rg_cache_enable = TRUE;
60 }
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/env.txt added (mode: 100644) (index 0000000..92e2275)
1 # Environments variables
2
3 # Without this line, I cannot use ssh on non standard port
4 GIT_SSH_VARIANT="ssh"
5
File tests/export.php changed (mode: 100644) (index 11cc673..6e9020d)
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("export.log"); rg_log_set_file("export.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 = 'export'; $_testns = 'export';
File tests/git.php changed (mode: 100644) (index 3928b57..cc0d9ab)
... ... if ($r['ok'] != 1) {
30 30 } }
31 31 $r = rg_git_merge_base('temp_repos/git_empty', 'master', $r = rg_git_merge_base('temp_repos/git_empty', 'master',
32 32 '3fa5ae7e933e33308a6f3ec70edcf2499c1914ac'); '3fa5ae7e933e33308a6f3ec70edcf2499c1914ac');
33 if (strcmp($r, $rg_git_zero) != 0) {
34 rg_log('On an empty repo, merge-base is not zero ($r)!');
33 if ($r !== $rg_git_empty) {
34 rg_log('Test must return ' . $rg_git_empty . ' but returned: ' . $r);
35 35 exit(1); exit(1);
36 36 } }
37 37 rg_log_exit(); rg_log_exit();
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/git2.sh changed (mode: 100755) (index a0c42f1..9ff2f7c)
... ... git checkout -b group2/subgroup1/branch2
12 12 git tag -a -m "aaaa" v1.0 git tag -a -m "aaaa" v1.0
13 13 git tag unannot1 git tag unannot1
14 14
15 git checkout master
16 echo "aaa" > b
17 git add b
18 git commit -m "commit b file"
File tests/git_big_push.php changed (mode: 100644) (index 13e2af2..54632cd)
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(__DIR__ . '/http.inc.php');
11 13
12 14 rg_log_set_file("git_big_push.log"); rg_log_set_file("git_big_push.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 = 'git_big_push'; $_testns = 'git_big_push';
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 !&quot;#$%&amp;&#039;()*+,-.0123456789:;&lt;=&gt;?</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 !&quot;#$%&amp;&#039;()*+,-.0123456789:;&lt;=&gt;?</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 !&quot;#$%&amp;&#039;()*+,-.0123456789:;&lt;=&gt;?</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 !&quot;#$%&amp;&#039;()*+,-.0123456789:;&lt;=&gt;?</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&lt;xss&gt;</b> added (mode: 100644) (index 0000000..e19d72a)</td></tr> <tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>a b c&lt;xss&gt;</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&quot;yy</b> added (mode: 100644) (index 0000000..1678aa7)</td></tr> <tr style="border: 1px; background: #dddddd"><td colspan="4">File <b>xx&quot;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/hook_update_help.php changed (mode: 100644) (index 6ba47e8..c4bc774)
... ... if (strcmp($op, "init") == 0) {
86 86 rg_sql_free_result($res); rg_sql_free_result($res);
87 87
88 88 $new = array('repo_id' => $repo_id, 'uid' => $repo_uid, 'public' => 0); $new = array('repo_id' => $repo_id, 'uid' => $repo_uid, 'public' => 0);
89 rg_test_create_repo($db, $rg_ui, $new);
89 rg_test_create_repo_no_dir($db, $rg_ui, $new);
90 90 } else if (strcmp($op, "repo") == 0) { } else if (strcmp($op, "repo") == 0) {
91 91 $v = rg_rights_set($db, "repo", $a); $v = rg_rights_set($db, "repo", $a);
92 92 if ($v === FALSE) { if ($v === FALSE) {
File tests/http_admin.php changed (mode: 100644) (index d20a160..575dc46)
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("http_admin.log"); rg_log_set_file("http_admin.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 = 'http_admin'; $_testns = 'http_admin';
File tests/http_bug.php changed (mode: 100644) (index 32c2641..51c6c52)
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("http_bug.log"); rg_log_set_file("http_bug.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 = 'http_bug'; $_testns = 'http_bug';
File tests/http_confirm.php changed (mode: 100644) (index 017d961..5f817bb)
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");
10 12
11 13 rg_log_set_file("http_confirm.log"); rg_log_set_file("http_confirm.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 = 'http_confirm'; $_testns = 'http_confirm';
 
... ... rg_log_exit();
69 69
70 70 rg_log_enter('Finding confirmation link...'); rg_log_enter('Finding confirmation link...');
71 71 $key = 'DEBUG::' . $uid . '::mail'; $key = 'DEBUG::' . $uid . '::mail';
72 $tries = 30;
73 while ($tries) {
74 $c = rg_cache_get($key);
75 if ($c !== FALSE)
76 break;
77
78 $tries--;
79 sleep(1);
80 }
81 if ($c === FALSE) {
82 rg_log('Cannot get key ' . $key . '!');
83 exit(1);
84 }
72 $c = test_wait_cache($key);
85 73 rg_log_ml('c: ' . print_r($c, TRUE)); rg_log_ml('c: ' . print_r($c, TRUE));
86 74 $c = $c['mail/user/welcome']; $c = $c['mail/user/welcome'];
87 75 $t = explode('below:', $c['body']); $t = explode('below:', $c['body']);
File tests/http_create_account.php changed (mode: 100644) (index a29ab51..408f3ce)
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");
10 12
11 13 rg_log_set_file("http_create_account.log"); rg_log_set_file("http_create_account.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 = 'http_create_account'; $_testns = 'http_create_account';
File tests/http_csrf.php changed (mode: 100644) (index 8a07a68..413dbe5)
... ... 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_csrf.log"); rg_log_set_file("http_csrf.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_csrf'; $_testns = 'http_csrf';
File tests/http_forgot.php changed (mode: 100644) (index 43eafb9..815ffee)
6 6 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
7 7 ini_set("track_errors", "On"); ini_set("track_errors", "On");
8 8
9 $test_normal = TRUE;
10
9 11 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
10 12 require_once(dirname(__FILE__) . "/config.php"); require_once(dirname(__FILE__) . "/config.php");
11 13 require_once($INC . "/init.inc.php"); require_once($INC . "/init.inc.php");
 
... ... require_once("http.inc.php");
15 17
16 18 rg_log_set_file("http_forgot.log"); rg_log_set_file("http_forgot.log");
17 19
18 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10";
19 $rg_no_db = TRUE;
20 20 require_once("common.php"); require_once("common.php");
21 21
22 22 $_testns = 'http_forgot'; $_testns = 'http_forgot';
 
... ... rg_log_exit();
67 67 rg_log(''); rg_log('');
68 68 rg_log_enter('Loading token from mail...'); rg_log_enter('Loading token from mail...');
69 69 $k = 'DEBUG::0::mail::mail/user/forgot/recover'; $k = 'DEBUG::0::mail::mail/user/forgot/recover';
70 $tries = 10;
71 while ($tries-- > 0) {
72 $c = rg_cache_get($k);
73 if ($c !== FALSE)
74 break;
75 sleep(1);
76 }
77 if (($c === FALSE) || !isset($c['body'])) {
70 $c = test_wait_cache($k);
71 if (!isset($c['body'])) {
78 72 rg_log_ml(print_r($c, TRUE)); rg_log_ml(print_r($c, TRUE));
79 rg_log('No c or no body in c var!');
73 rg_log('No body in c var!');
80 74 exit(1); exit(1);
81 75 } }
82 76 $s = strstr($c['body'], '/op/forgot_link/'); $s = strstr($c['body'], '/op/forgot_link/');
File tests/http_keys.php changed (mode: 100644) (index c443a52..0c55873)
... ... 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_keys.log'); rg_log_set_file('http_keys.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_keys'; $_testns = 'http_keys';
File tests/http_login.php changed (mode: 100644) (index ed98c6c..a268b87)
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("http_login.log"); rg_log_set_file("http_login.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 = 'http_login'; $_testns = 'http_login';
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/http_top.php changed (mode: 100644) (index 763891b..4dbc8e0)
... ... 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_top.log"); rg_log_set_file("http_top.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_top'; $_testns = 'http_top';
 
... ... prepare_http();
24 23
25 24 // TODO: donate has some problems with input + border (tidy)! // TODO: donate has some problems with input + border (tidy)!
26 25 $_list = array("features", "discover", "download", "pricing", "tos", $_list = array("features", "discover", "download", "pricing", "tos",
27 "create_account", "login");
26 "create_account", "login", "stats");
28 27 foreach ($_list as $op) { foreach ($_list as $op) {
29 28 rg_log("Loading $op page..."); rg_log("Loading $op page...");
30 29 $data = array(); $data = array();
File tests/http_totp.php changed (mode: 100644) (index 2eb88aa..578e7f5)
6 6 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
7 7 ini_set("track_errors", "On"); ini_set("track_errors", "On");
8 8
9 $test_normal = TRUE;
10
9 11 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
10 12 require_once(dirname(__FILE__) . "/config.php"); require_once(dirname(__FILE__) . "/config.php");
11 13 require_once($INC . "/init.inc.php"); require_once($INC . "/init.inc.php");
 
... ... require_once("http.inc.php");
15 17
16 18 rg_log_set_file("http_totp.log"); rg_log_set_file("http_totp.log");
17 19
18 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10";
19 $rg_no_db = TRUE;
20 20 require_once("common.php"); require_once("common.php");
21 21
22 22 $_testns = 'http_totp'; $_testns = 'http_totp';
File tests/ldap.php changed (mode: 100644) (index 6fa5ff6..29c9e08)
... ... ini_set('track_errors', 'On');
5 5 $rg_cache_debug = TRUE; $rg_cache_debug = TRUE;
6 6 $rg_util_debug = TRUE; $rg_util_debug = TRUE;
7 7 $rg_sql_debug = 100; $rg_sql_debug = 100;
8 $test_normal = TRUE;
8 9
9 10 $INC = dirname(__FILE__) . '/../inc'; $INC = dirname(__FILE__) . '/../inc';
10 11 require_once(dirname(__FILE__) . '/config.php'); require_once(dirname(__FILE__) . '/config.php');
 
... ... require_once('http.inc.php');
17 18
18 19 rg_log_set_file('ldap.log'); rg_log_set_file('ldap.log');
19 20
20 $rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10';
21 $rg_no_db = TRUE;
22 21 require_once('common.php'); require_once('common.php');
23 22
24 23 $_testns = 'admin_ldap'; $_testns = 'admin_ldap';
 
... ... $res = rg_sql_query($db, $sql);
507 506 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
508 507 rg_sql_free_result($res); rg_sql_free_result($res);
509 508 $key = 'ldap::list::' . $id; $key = 'ldap::list::' . $id;
510 rg_cache_core_unset($key); // else we will get previous copy!
511 $c = rg_cache_get($key);
509 $c = test_wait_cache($key);
512 510 foreach ($data as $k => $v) { foreach ($data as $k => $v) {
513 511 // ignore some fields // ignore some fields
514 512 if (strncmp($k, 'ldap::', 6) != 0) if (strncmp($k, 'ldap::', 6) != 0)
File tests/ldap_core.php changed (mode: 100644) (index c2c71de..49721f7)
... ... ini_set('track_errors', 'On');
5 5 $rg_cache_debug = TRUE; $rg_cache_debug = TRUE;
6 6 $rg_util_debug = TRUE; $rg_util_debug = TRUE;
7 7 $rg_sql_debug = 100; $rg_sql_debug = 100;
8 $test_normal = TRUE;
8 9
9 10 $INC = dirname(__FILE__) . '/../inc'; $INC = dirname(__FILE__) . '/../inc';
10 11 require_once(dirname(__FILE__) . '/config.php'); require_once(dirname(__FILE__) . '/config.php');
 
... ... require_once($INC . '/ldap_core.inc.php');
14 15
15 16 rg_log_set_file('ldap_core.log'); rg_log_set_file('ldap_core.log');
16 17
17 $rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10';
18 $rg_no_db = TRUE;
19 18 require_once('common.php'); require_once('common.php');
20 19
21 20 $_testns = 'admin_ldap_core'; $_testns = 'admin_ldap_core';
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/repo.php changed (mode: 100644) (index eede1b4..24e5603)
... ... rg_log_exit();
193 193 $rg_repo_allow = $old_allow; $rg_repo_allow = $old_allow;
194 194 $rg_repo_max_len = 50; $rg_repo_max_len = 50;
195 195
196 rg_test_create_repo($db, $rg_ui, $new);
196 rg_test_create_repo_no_dir($db, $rg_ui, $new);
197 197 $repo_id = $new['repo_id']; $repo_id = $new['repo_id'];
198 198
199 199 $ri = rg_repo_info($db, $repo_id, 0, ""); $ri = rg_repo_info($db, $repo_id, 0, "");
File tests/source.php changed (mode: 100644) (index c76e1d9..c54634c)
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("source.log"); rg_log_set_file("source.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 = 'source'; $_testns = 'source';
 
... ... if ($r === FALSE) {
31 31 } }
32 32
33 33
34 rg_log('');
35 rg_log_enter('Uploading a key...');
36 rg_test_upload_ssh_key($db, $rg_ui, 'source');
37 rg_log_exit();
34 rg_test_upload_ssh_key($db, $rg_ui, 'source', $kn);
38 35
39 36
40 37 rg_log(''); rg_log('');
 
... ... $r = rg_exec('mkdir -p temp_repos && cd temp_repos'
47 44 . ' && rm -rf .source && mkdir .source && cd .source' . ' && rm -rf .source && mkdir .source && cd .source'
48 45 . ' && git init && git commit --allow-empty -m "' . $cmsg . '"' . ' && git init && git commit --allow-empty -m "' . $cmsg . '"'
49 46 . ' && git remote add origin ' . $remote . ' && git remote add origin ' . $remote
50 . ' && export GIT_SSH_COMMAND="ssh -v -o ControlMaster=no -o IdentityFile=../../keys/source -o IdentitiesOnly=yes"'
47 . ' && export GIT_SSH_COMMAND="ssh -v -o ControlMaster=no -o IdentityFile=../../keys/' . $kn . ' -o IdentitiesOnly=yes"'
51 48 . ' && git push origin master', . ' && git push origin master',
52 49 '', FALSE, FALSE, FALSE); '', FALSE, FALSE, FALSE);
53 50 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
File tests/sql-fork.php changed (mode: 100644) (index 65e474d..8e7fe49)
... ... error_reporting(E_ALL | E_STRICT);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 5 $rg_sql_debug = 100; $rg_sql_debug = 100;
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($INC . '/sql.inc.php');
12 13
13 14 rg_log_set_file('sql-fork.log'); rg_log_set_file('sql-fork.log');
14 15
15 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10";
16 $rg_no_db = TRUE;
17 16 require_once('common.php'); require_once('common.php');
18 17
19 18 $sql = 'SELECT 1'; $sql = 'SELECT 1';
File tests/ssh.php changed (mode: 100644) (index 35d6015..3daff19)
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("ssh.log"); rg_log_set_file("ssh.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 = 'ssh'; $_testns = 'ssh';
 
... ... if ($r === FALSE) {
42 42 rg_log_exit(); rg_log_exit();
43 43
44 44
45 rg_test_upload_ssh_key($db, $rg_ui, $rg_ui['uid']);
45 rg_test_upload_ssh_key($db, $rg_ui, 'ssh', $kn);
46 46
47 47
48 48 rg_log(''); rg_log('');
File tests/util.php changed (mode: 100644) (index 777a935..605e201)
... ... function cb_tick($index, &$a)
416 416 $a['my'] = 'tick_was_here'; $a['my'] = 'tick_was_here';
417 417
418 418 if (isset($a['cb_output_called']) && isset($a['cb_input_called'])) { if (isset($a['cb_output_called']) && isset($a['cb_input_called'])) {
419 rg_log('cb_tick[' . $index . ']: set output_done to 1');
420 $a['output_done'] = 1;
419 rg_log('cb_tick[' . $index . ']: set out_buf_done to 1');
420 $a['out_buf_done'] = 1;
421 421 } }
422 422 } }
423 423
 
... ... $a = array(
432 432 'cb_finish' => 'cb_finish', 'cb_finish' => 'cb_finish',
433 433 'cb_tick' => 'cb_tick', 'cb_tick' => 'cb_tick',
434 434 'out_buf' => 'aaa1', 'out_buf' => 'aaa1',
435 'output_done' => 0
435 'out_buf_done' => 0
436 436 ), ),
437 437 'cmd2' => array( 'cmd2' => array(
438 438 'cmd' => 'echo first2; read a; sleep .2; echo last2; echo "err2-[${a}]" 1>&2', 'cmd' => 'echo first2; read a; sleep .2; echo last2; echo "err2-[${a}]" 1>&2',
 
... ... $a = array(
443 443 'cb_finish' => 'cb_finish', 'cb_finish' => 'cb_finish',
444 444 'cb_tick' => 'cb_tick', 'cb_tick' => 'cb_tick',
445 445 'out_buf' => 'aaa2', 'out_buf' => 'aaa2',
446 'output_done' => 0
446 'out_buf_done' => 0
447 447 ) )
448 448 ) )
449 449 ); );
 
... ... if (!isset($r['cmds']['cmd2']['my']) || (strcmp($r['cmds']['cmd2']['my'], $e) !=
479 479 rg_log_exit(); rg_log_exit();
480 480
481 481
482 rg_log('');
483 $t = 'test input decompression';
484 rg_log_enter($t);
485 $in = 'this is a test string to be decompressed';
486 $input = gzencode($in);
487 $a = array(
488 'cmds' => array(
489 'cmd1' => array(
490 'cmd' => 'cat',
491 'out_buf' => $input,
492 'out_buf_helper' => 'rg_exec2_helper_gzip_in',
493 'out_buf_done' => 0
494 )
495 )
496 );
497 $r = rg_exec2($a);
498 if ($r['ok'] != 1) {
499 rg_log('rg_exec2 failed: ' . $r['errmsg'] . '!');
500 exit(1);
501 }
502 rg_log_ml('r: ' . print_r($r, TRUE));
503 if (strcmp($r['cmds']['cmd1']['in_buf'], $in) != 0) {
504 rg_log('cmd1 in_buf is not ok: ['
505 . $r['cmds']['cmd1']['in_buf'] . '] != [' . $in . ']!');
506 exit(1);
507 }
508 rg_log_exit();
509
482 510 rg_log(''); rg_log('');
483 511 $t = "test rg_template_table(dir, data, more) with no data"; $t = "test rg_template_table(dir, data, more) with no data";
484 512 rg_log_enter($t); rg_log_enter($t);
File tests/wh-helper.sh changed (mode: 100755) (index a7c05bc..9335959)
1 1 #!/bin/bash #!/bin/bash
2 2
3 read req
3 port=${1}; shift
4
5 log="wh-helper-${port}.log"
6 echo "`date`: Starting..." >"${log}"
7
8 while read -t3 line; do
9 E=${?}
10 echo "`date`: Readed[E=${E}]: ${line}" >>"${log}"
11 if [ "${E}" != "0" ]; then
12 echo "Done reading request" >>"${log}"
13 break
14 fi
15 done
16 echo "`date`: After while: ?=${?} [line=${line}]" >>"${log}"
4 17
5 18 echo -n -e "HTTP/1.1 200 OK\r\n" echo -n -e "HTTP/1.1 200 OK\r\n"
6 19 echo -n -e "Content-Length: 4\r\n" echo -n -e "Content-Length: 4\r\n"
7 20 echo -n -e "\r\n" echo -n -e "\r\n"
8 21 echo "OK!" echo "OK!"
22
23 echo "`date`: Done sending data" >>"${log}"
File tests/wh-stunnel.conf changed (mode: 100644) (index 55cacb6..e2c05b4)
1 debug = 7
1 debug = debug
2 2 log = overwrite log = overwrite
3 3 CAfile = ca/wh/certs/cacert.pem CAfile = ca/wh/certs/cacert.pem
4 4 cert = ca/wh/certs/localhost.pem cert = ca/wh/certs/localhost.pem
 
... ... key = ca/wh/private/localhost.key
6 6 output = @@cwd@@/wh-stunnel-@@id@@.log output = @@cwd@@/wh-stunnel-@@id@@.log
7 7 foreground = yes foreground = yes
8 8 exec = @@cwd@@/wh-helper.sh exec = @@cwd@@/wh-helper.sh
9 execArgs = @@cwd@@/wh-helper.sh @@port@@
9 10 syslog = no syslog = no
10 11 socket = a:SO_REUSEADDR=yes socket = a:SO_REUSEADDR=yes
11 12
File tests/wh_cloud.git.sh changed (mode: 100755) (index bb99f0f..c4b90a3)
3 3 set -e set -e
4 4 set -u set -u
5 5
6 export GIT_SSH_COMMAND="ssh -o ControlMaster=no -o IdentityFile=${PWD}/keys/wh_cloud -o IdentitiesOnly=yes"
6 export GIT_SSH_COMMAND="ssh -o ControlMaster=no -o IdentityFile=${PWD}/keys/${RG_SSH_KEY} -o IdentitiesOnly=yes"
7 7
8 8 echo "Cloning repo..." echo "Cloning repo..."
9 9 rm -rf wh_cloud.git rm -rf wh_cloud.git
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!');
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main