* Fix bug #41288, check access for testtask.

This commit is contained in:
zhujinyong
2023-12-12 11:06:59 +08:00
parent 03c58d7b39
commit 30e3940b80
3 changed files with 38 additions and 3 deletions
+36 -3
View File
@@ -295,6 +295,7 @@ class testtask extends control
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
return print(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index')));
}
$this->checkAccess($task);
/* When the session changes, you need to query the related products again. */
if($this->session->project != $task->project) $this->view->products = $this->products = $this->product->getProductPairsByProject($task->project);
@@ -444,6 +445,34 @@ class testtask extends control
$this->display();
}
/**
* Check access.
*
* @param object $testtask
* @access private
* @return bool
*/
private function checkAccess($testtask)
{
$canAccess = true;
$view = $this->app->user->view;
if(!$this->app->user->admin)
{
if($testtask->product && strpos(",{$view->products},", ",$testtask->product,") === false) $canAccess = false;
if($testtask->project && strpos(",{$view->projects},", ",$testtask->project,") === false) $canAccess = false;
if($testtask->execution && strpos(",{$view->sprints},", ",$testtask->execution,") === false) $canAccess = false;
}
if($canAccess) return true;
echo(js::alert($this->lang->testtask->accessDenied));
echo js::locate(helper::createLink('testtask', 'browse'));
return false;
}
/**
* Browse cases of a test task.
*
@@ -478,6 +507,8 @@ class testtask extends control
$task = $this->testtask->getById($taskID);
if(!$task) return print(js::error($this->lang->testtask->checkLinked) . js::locate('back'));
$this->checkAccess($task);
$productID = $task->product;
$product = $this->product->getByID($productID);
if(!isset($this->products[$productID])) $this->products[$productID] = $product->name;
@@ -605,6 +636,7 @@ class testtask extends control
$this->view->charts = array();
$task = $this->testtask->getById($taskID);
$this->checkAccess($task);
if(!empty($_POST))
{
@@ -1089,6 +1121,7 @@ class testtask extends control
$product = $this->product->getByID($productID);
if(!isset($this->products[$productID])) $this->products[$productID] = $product->name;
$this->checkAccess($task);
/* Save session. */
if($this->app->tab == 'project')
@@ -1662,9 +1695,9 @@ class testtask extends control
}
/**
* AJAX: Get executionID by buildID.
*
* @param int $buildID
* AJAX: Get executionID by buildID.
*
* @param int $buildID
* @access public
* @return int
*/
+1
View File
@@ -156,6 +156,7 @@ $lang->testtask->titleOfAuto = "%s automated testing";
$lang->testtask->cannotBeParsed = 'The content of the imported XML file is in the wrong format and cannot be parsed.';
$lang->testtask->finishedDateLess = 'Actual Finished Date cannot be <= Begin Date %s';
$lang->testtask->finishedDateMore = 'Actual Finished Date cannot be > Today';
$lang->testtask->accessDenied = 'You have no access to the testtask.';
$lang->testtask->assignedToMe = 'AssignedToMe';
$lang->testtask->allCases = 'All Cases';
+1
View File
@@ -156,6 +156,7 @@ $lang->testtask->titleOfAuto = "%s 自动化测试";
$lang->testtask->cannotBeParsed = '导入的XML文件内容格式错误,无法解析。';
$lang->testtask->finishedDateLess = '实际完成日期不能小于开始日期%s';
$lang->testtask->finishedDateMore = '实际完成日期不能大于今天';
$lang->testtask->accessDenied = '您无权访问该测试单';
$lang->testtask->assignedToMe = '指派给我';
$lang->testtask->allCases = '全部用例';