<?php error_reporting(E_ALL | E_STRICT); ini_set("track_errors", "On"); $test_normal = TRUE; $rg_cache_debug = TRUE; $INC = dirname(__FILE__) . "/../inc"; require_once(dirname(__FILE__) . "/config.php"); require_once($INC . "/init.inc.php"); require_once($INC . "/bug.inc.php"); require_once($INC . "/sql.inc.php"); require_once($INC . "/struct.inc.php"); require_once($INC . "/fixes.inc.php"); require_once("helpers.inc.php"); rg_log_set_file("bug.log"); require_once("common.php"); $_testns = 'bug'; rg_test_create_user($db, $u1); rg_test_create_user($db, $u2); rg_test_create_repo($db, $u1, $new); $data = array("bug_id" => 0, "title" => "Bug title<xss>", "body" => "This is the body\nof the\nbug.<xss>", "labels" => "label2,label1<xss>", "state" => 1, "assigned_uid" => 6); $ri = array("repo_id" => $new['repo_id'], "name" => "repoX"); $r = rg_bug_edit($db, $u1, $ri, $data); if ($r === FALSE) { rg_log("Cannot insert a bug (" . rg_bug_error() . ")!"); exit(1); } $bug_id = $r; // verify that labels were inserted $r = rg_bug_label_get($db, $new['repo_id'], $bug_id); if ($r === FALSE) { rg_log("Cannot get labels (" . rg_bug_error() . ")!"); exit(1); } if (strcmp($r[0], "label1<xss>") != 0) { rg_log("Ordering the labels seems to not work."); exit(1); } if (strcmp($r[1], "label2") != 0) { rg_log("Ordering the labels seems to not work."); exit(1); } $data = array("note" => "This is just a note.<xss>"); $r = rg_bug_note_add($db, $new['repo_id'], $bug_id, $u2['uid'], $data); if ($r === FALSE) { rg_log("Cannot add a note by u2 (" . rg_bug_error() . ")!"); exit(1); } $r = rg_bug_info($db, $new['repo_id'], $bug_id); if ($r['exists'] != 1) { rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!"); exit(1); } // test a non existing bug $r = rg_bug_info($db, $new['repo_id'], 0); if ($r['exists'] != 0) { rg_log("Wrong bug number (0) returned valid data!"); exit(1); } // Search bugs $q = array("reported_by" => $u1['username'], "assigned_to" => $u2['username'], "state" => "1", "start" => "2000-01-01", "end" => "2001-01-01", "title_string" => "IMPOSSIBLE TITLE<xss>", "body_string" => "IMPOSSIBLE BODY<xss>", "bugs_per_page" => "1"); $r = rg_bug_search($db, $new['repo_id'], $u1['uid'], $q); if ($r === FALSE) { rg_log("Cannot search bugs 1 (" . rg_bug_error() . ")!"); exit(1); } if (count($r) > 0) { rg_log("Search 1 returned a bug but the filtering should not allow it!"); exit(1); } $q = array("title_string" => "g t", "body_string" => ""); $r = rg_bug_search($db, $new['repo_id'], $u1['uid'], $q); if ($r === FALSE) { rg_log("Cannot search bugs 2 (" . rg_bug_error() . ")!"); exit(1); } if (count($r) == 0) { rg_log("Search 2 did not returned a bug we were expecting!"); exit(1); } rg_sql_close($db); rg_log("OK!"); ?>