Skip to content

added API function to retrieve a testsuite's attachments #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions lib/api/xmlrpc/v1/xmlrpc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,54 @@ protected function _getBugsForExecutionId($execution_id)
}


/**
* Gets attachments for specified test suite.
* The attachment file content is Base64 encoded. To save the file to disk in client,
* Base64 decode the content and write file in binary mode.
*
* @param struct $args
* @param string $args["devKey"] Developer key
* @param int $args["testsuiteid"]: id of the testsuite
*
* @return mixed $resultInfo
* @author dennis@etern-it.de
*/
public function getTestSuiteAttachments($args)
{
$this->_setArgs($args);
$attachments=null;
$checkFunctions = array('authenticate','checkTestSuiteID');
$status_ok = $this->_runChecks($checkFunctions) &&
$this->userHasRight("mgt_view_tc",self::CHECK_PUBLIC_PRIVATE_ATTR);

if($status_ok)
{
$tsuite_id = $this->args[self::$testSuiteIDParamName];
$attachmentRepository = tlAttachmentRepository::create($this->dbObj);
$attachmentInfos = $attachmentRepository->getAttachmentInfosFor($tsuite_id,"nodes_hierarchy");

if ($attachmentInfos)
{
foreach ($attachmentInfos as $attachmentInfo)
{
$aID = $attachmentInfo["id"];
$content = $attachmentRepository->getAttachmentContent($aID, $attachmentInfo);

if ($content != null)
{
$attachments[$aID]["id"] = $aID;
$attachments[$aID]["name"] = $attachmentInfo["file_name"];
$attachments[$aID]["file_type"] = $attachmentInfo["file_type"];
$attachments[$aID]["title"] = $attachmentInfo["title"];
$attachments[$aID]["date_added"] = $attachmentInfo["date_added"];
$attachments[$aID]["content"] = base64_encode($content);
}
}
}
}
return $status_ok ? $attachments : $this->errors;
}


/**
* Gets attachments for specified test case.
Expand Down Expand Up @@ -7999,6 +8047,7 @@ function initMethodYellowPages()
'tl.getRequirementCustomFieldDesignValue' => 'this:getRequirementCustomFieldDesignValue',
'tl.getFirstLevelTestSuitesForTestProject' => 'this:getFirstLevelTestSuitesForTestProject',
'tl.getTestCaseAttachments' => 'this:getTestCaseAttachments',
'tl.getTestSuiteAttachments' => 'this:getTestSuiteAttachments',
'tl.getTestCase' => 'this:getTestCase',
'tl.getFullPath' => 'this:getFullPath',
'tl.getTestSuiteByID' => 'this:getTestSuiteByID',
Expand Down