Skip to content

Commit 67087b6

Browse files
committed
Contribution -Fix for userHasRight function #365
The following functions have issues with user rights checking because they do not specify providing Test Plan or Test project ID. This fix adds a lookup in the userHasRight() function. getTestSuiteAttachments getTestCaseAttachments getTestSuiteByID getTestSuitesForTestSuite uploadTestSuiteAttachment createTestCaseSteps deleteTestCaseSteps createPlatform deleteTestProject
1 parent 23e98ec commit 67087b6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

lib/api/xmlrpc/v1/xmlrpc.class.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,29 @@ protected function userHasRight($rightToCheck, $checkPublicPrivateAttr = false,
468468
$tprojectid = intval( $dummy['tproject_id'] );
469469
}
470470

471+
// Contribution by frankfal
472+
// Some APIs only provide TestSuiteID or TestCaseID, look up TestProjectID
473+
if ($tprojectid <= 0 && $tplanid == -1) {
474+
// Try using TestSuiteID to get TestProjectID
475+
$tsuitid = intval( isset( $context[self::$testSuiteIDParamName] ) ? $context[self::$testSuiteIDParamName] : 0 );
476+
if($tsuiteid == 0 && isset( $this->args[self::$testSuiteIDParamName] )) {
477+
$tsuiteid = intval( $this->args[self::$testSuiteIDParamName] );
478+
}
479+
if ($tsuiteid > 0) {
480+
$dummy = $this->tprojectMgr->tree_manager->get_path( $tsuiteid );
481+
$tprojectid = $dummy[0]['parent_id'];
482+
} else {
483+
// Try using TestCaseID to get TestProjectID
484+
$tcaseid = intval( isset( $context[self::$testCaseIDParamName] ) ? $context[self::$testCaseIDParamName] : 0 );
485+
if($tcaseid == 0 && isset( $this->args[self::$testCaseIDParamName] )) {
486+
$tcaseid = intval( $this->args[self::$testCaseIDParamName] );
487+
}
488+
if ($tcaseid > 0) {
489+
$tprojectid = $this->tcaseMgr->get_testproject( $tcaseid );
490+
}
491+
}
492+
}
493+
471494
if(! $this->user->hasRight( $this->dbObj, $rightToCheck, $tprojectid, $tplanid, $checkPublicPrivateAttr )) {
472495
$status_ok = false;
473496
$msg = sprintf( INSUFFICIENT_RIGHTS_STR, $this->user->login, $rightToCheck, $tprojectid, $tplanid );

0 commit comments

Comments
 (0)