From 4e1f1488e2a68de4cd8f894f8944a7d98e4548f8 Mon Sep 17 00:00:00 2001 From: Patrick Delcroix Date: Thu, 25 Mar 2021 10:32:50 +0100 Subject: [PATCH 1/3] Copy the steps and execution notes for failed tc if the test is failed, if the step is not passed or there is an execution note then this is added to the "note/description" Step (): --- gui/javascript/execSetResults.js | 39 ++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/gui/javascript/execSetResults.js b/gui/javascript/execSetResults.js index b7a4f55585..2dfbba9998 100644 --- a/gui/javascript/execSetResults.js +++ b/gui/javascript/execSetResults.js @@ -26,22 +26,43 @@ function doSubmitForHTML5() { * */ function saveExecStatus(tcvID, status, msg, goNext) { - /* Init */ jQuery('#save_and_next').val(0); - jQuery('#save_results').val(0); - jQuery('#save_partial_steps_exec').val(0); + jQuery('#save_results').val(0); + jQuery('#save_partial_steps_exec').val(0); jQuery('#save_button_clicked').val(tcvID); jQuery('#statusSingle_' + tcvID).val(status); + if(status == 'f'){ + // Get all steps status + var myRegexp = /step_row_(\d+)/g; + var stepresult = document.querySelectorAll('[id^=step_row_]') + var tcNotes = document.getElementById('notes['+tcvID+']'); + stepresult.forEach(function(item){ + match = myRegexp.exec(item.id); + myRegexp.lastIndex = 0; + stepNum = document.getElementById('tcstep_'+match[1]); + var row = stepNum.innerHTML; + var note = ''; + var statusTc = '' + + + if ( item.getElementsByClassName('step_status').length > 0 ) + statusTc = item.getElementsByClassName('step_status')[0].value; + if ( item.getElementsByClassName('step_note_textarea').length > 0 ) + note = item.getElementsByClassName('step_note_textarea')[0].value; + if (statusTc == 'f' ||statusTc == 'b' || note != ''){ + tcNotes.value = tcNotes.value + '\nStep '+ row + ' ('+ statusTc+'):' + note ; + } + }) + } if( goNext == undefined || goNext == 0 ) { - jQuery('#save_results').val(1); + jQuery('#save_results').val(1); } else { - if( goNext == 1 ) { - jQuery('#save_and_next').val(1); - } + if( goNext == 1 ) { + jQuery('#save_and_next').val(1); + } } - doSubmitForHTML5(); } @@ -152,4 +173,4 @@ function checkSubmitForStatusCombo(oid,statusCode2block) { saveStepsPartialExecClicked = false; $("#saveStepsPartialExec").click(function() { saveStepsPartialExecClicked = true; -}); \ No newline at end of file +}); From 5af2548ba250b72616ead5710686840507dbf643 Mon Sep 17 00:00:00 2001 From: Patrick Delcroix Date: Mon, 19 Jul 2021 11:12:36 +0200 Subject: [PATCH 2/3] merge upstream --- .../tl-classic/requirements/reqTcAssign.tpl | 15 ++++--- .../DB.1.9.20/step1/db_schema_update.sql | 2 +- lib/functions/oauth_providers/github.php | 40 ++++++++++++++++++- .../jirarestInterface.class.php | 15 ++++--- third_party/fayp-jira-rest/Jira.php | 38 +++++++++++++++++- 5 files changed, 93 insertions(+), 17 deletions(-) diff --git a/gui/templates/tl-classic/requirements/reqTcAssign.tpl b/gui/templates/tl-classic/requirements/reqTcAssign.tpl index a9fb0e1011..266cb352dd 100644 --- a/gui/templates/tl-classic/requirements/reqTcAssign.tpl +++ b/gui/templates/tl-classic/requirements/reqTcAssign.tpl @@ -58,8 +58,6 @@ function refreshAndClose(tcase_id,callback) { {$msgReqLinkingEnabled = $labels.reqLinkingDisabledAfterExec} {/if} - - {$sep = $smarty.const.TITLE_SEP} {$tcIdentity = "{$gui->tcTitle|escape} "} @@ -83,9 +81,10 @@ function refreshAndClose(tcase_id,callback) { {/if}

{$labels.req_spec} - + {html_options options=$gui->arrReqSpec selected=$gui->selectedReqSpec} - +

{if $gui->showCloseButton}
@@ -239,5 +238,11 @@ function refreshAndClose(tcase_id,callback) {
{/if} + + - \ No newline at end of file + diff --git a/install/sql/alter_tables/1.9.20/mysql/DB.1.9.20/step1/db_schema_update.sql b/install/sql/alter_tables/1.9.20/mysql/DB.1.9.20/step1/db_schema_update.sql index e3d151c2cc..412f772e63 100644 --- a/install/sql/alter_tables/1.9.20/mysql/DB.1.9.20/step1/db_schema_update.sql +++ b/install/sql/alter_tables/1.9.20/mysql/DB.1.9.20/step1/db_schema_update.sql @@ -67,7 +67,7 @@ CREATE TABLE /*prefix*/baseline_l1l2_context ( end_exec_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, creation_ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), - UNIQUE KEY /*prefix*/udx1_details (testplan_id,platform_id,creation_ts) + UNIQUE KEY udx1 (testplan_id,platform_id,creation_ts) ) DEFAULT CHARSET=utf8; diff --git a/lib/functions/oauth_providers/github.php b/lib/functions/oauth_providers/github.php index 9011b72f64..5d63d6ada0 100644 --- a/lib/functions/oauth_providers/github.php +++ b/lib/functions/oauth_providers/github.php @@ -67,7 +67,45 @@ function oauth_get_token($authCfg, $code) var_dump($user->getNickname()); echo ''; die(); - */ + } + curl_close($curl); + $tokenInfo = json_decode($result_curl); + + // If token is received start session + if (isset($tokenInfo->access_token)) { + $oauthParams['access_token'] = $tokenInfo->access_token; + $curlContentType = array('Authorization: token ' . $tokenInfo->access_token, 'Content-Type: application/xml','Accept: application/json'); + + $queryString = http_build_query($tokenInfo); + $targetURL = array(); + $targetURL['user'] = $authCfg['oauth_profile'] . '?' . $queryString; + $targetURL['email'] = $authCfg['oauth_profile'] . '/emails?'. $queryString; + + // Get User + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $targetURL['user']); + curl_setopt($curl, CURLOPT_USERAGENT, $curlAgent); + curl_setopt($curl, CURLOPT_HTTPHEADER, $curlContentType); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $result_curl = curl_exec($curl); + $userInfo = json_decode($result_curl, true); + curl_close($curl); + + if (!isset($userInfo['login'])) { + $result->status['msg'] = 'User ID is empty'; + $result->status['status'] = tl::ERROR; + } + + // Get email + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $targetURL['email'] ); + curl_setopt($curl, CURLOPT_USERAGENT, $curlAgent); + curl_setopt($curl, CURLOPT_HTTPHEADER, $curlContentType); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $result_curl = curl_exec($curl); + $emailInfo = json_decode($result_curl, true); + curl_close($curl); + $firstLast = $user->getName(); $result->options = new stdClass(); diff --git a/lib/issuetrackerintegration/jirarestInterface.class.php b/lib/issuetrackerintegration/jirarestInterface.class.php index 4b688260ca..050ef8ab79 100644 --- a/lib/issuetrackerintegration/jirarestInterface.class.php +++ b/lib/issuetrackerintegration/jirarestInterface.class.php @@ -387,14 +387,13 @@ public function addIssue($summary,$description,$opt=null) } } - - if (property_exists($opt, 'reporter')) { - - // After Atlassian GDRP Changes - // $issue['fields']['reporter'] = - // array('name' => (string)$opt->reporter); - $issue['fields']['reporter'] = - array('id' => (string)$opt->reporter); + if (property_exists($opt, 'reporter')) { + $accountid = $this->APIClient->getAccountId($opt->reporter_email); + if($accountid) { + $issue['fields']['reporter'] = array('accountId' => (string)$accountid); + } else { + $issue['fields']['reporter'] = array('name' => (string)$opt->reporter); + } } if (property_exists($opt, 'issueType')) { diff --git a/third_party/fayp-jira-rest/Jira.php b/third_party/fayp-jira-rest/Jira.php index 9f43c72ac1..1bac99f920 100644 --- a/third_party/fayp-jira-rest/Jira.php +++ b/third_party/fayp-jira-rest/Jira.php @@ -541,5 +541,39 @@ public function getCreateIssueMetadata($projectKeys=null,$opt=null) return $items; } - -} \ No newline at end of file + /** + * getAccountId + * + * @return mixed + */ + public function getAccountId($email) + { + $cmd = $this->host . 'groupuserpicker?query=' . $email; + $this->request->openConnect($cmd, 'GET'); + $this->request->execute(); + if ($result = json_decode($this->request->getResponseBody())) { + if (!isset($result->users)) { + //error_log('cannot find user'); + return false; + } + $infos = $result->users->users; + $cnt = $result->users->total; + if ($infos) { + foreach ($infos as $info) { + if ($info->accountId) { + return $info->accountId; + } + } + } + return false; + } + else + { + // ATTENTION \Exception in order to use PHP object. + $msg = "Error Processing Request - " . __METHOD__ . ' ' . + implode('/', $items->errorMessages); + throw new \Exception($msg, 999); + } + return false; + } +} From 6efca226f02b063f1f8aca91549827bb7cf77993 Mon Sep 17 00:00:00 2001 From: Patrick Delcroix Date: Mon, 19 Jul 2021 11:13:03 +0200 Subject: [PATCH 3/3] add config for step note concat --- Dockerfile | 5 ++ config.inc.php | 6 +++ gui/javascript/execSetResults.js | 48 ++++++++++--------- .../execute/inc_exec_img_controls.tpl | 4 +- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index c10a1a693b..c5a2c3d6a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,3 +8,8 @@ RUN /etc/init.d/mysql 'start' WORKDIR /var/www/public COPY . ./ + +RUN mkdir /var/testlink/logs -p &&\ + mkdir /var/testlink/upload_area -p &&\ + chmod a+rw /var/www/public/gui/templates_c &&\ + chmod a+rw /var/testlink -R diff --git a/config.inc.php b/config.inc.php index 02d3bd5342..192e4bbb76 100644 --- a/config.inc.php +++ b/config.inc.php @@ -1078,6 +1078,12 @@ // 'latest' => latest execution notes. $tlCfg->exec_cfg->steps_exec_status_default = 'empty'; +/** + * Concatenate execution steps note in the execution notes (the later is attached to the test run) + **/ + +$tlCfg->exec_cfg->steps_notes_concat = false; + // Parameters to show notes/details when entering test execution feature // EXPAND: show expanded/open // COLLAPSE: show collapsed/closede diff --git a/gui/javascript/execSetResults.js b/gui/javascript/execSetResults.js index 2dfbba9998..307c611d72 100644 --- a/gui/javascript/execSetResults.js +++ b/gui/javascript/execSetResults.js @@ -23,9 +23,13 @@ function doSubmitForHTML5() { /** * Submit Executions status. * Used - * + * @param tcvID int test case id + * @param status test status + * @param notesConcat concatenate step note in exec notes + * @param goNext open next test case + * */ -function saveExecStatus(tcvID, status, msg, goNext) { +function saveExecStatus(tcvID, status, notesConcat, goNext) { /* Init */ jQuery('#save_and_next').val(0); jQuery('#save_results').val(0); @@ -33,28 +37,26 @@ function saveExecStatus(tcvID, status, msg, goNext) { jQuery('#save_button_clicked').val(tcvID); jQuery('#statusSingle_' + tcvID).val(status); - if(status == 'f'){ + if(notesConcat == true){ // Get all steps status - var myRegexp = /step_row_(\d+)/g; - var stepresult = document.querySelectorAll('[id^=step_row_]') - var tcNotes = document.getElementById('notes['+tcvID+']'); - stepresult.forEach(function(item){ - match = myRegexp.exec(item.id); - myRegexp.lastIndex = 0; - stepNum = document.getElementById('tcstep_'+match[1]); - var row = stepNum.innerHTML; - var note = ''; - var statusTc = '' - - - if ( item.getElementsByClassName('step_status').length > 0 ) - statusTc = item.getElementsByClassName('step_status')[0].value; - if ( item.getElementsByClassName('step_note_textarea').length > 0 ) - note = item.getElementsByClassName('step_note_textarea')[0].value; - if (statusTc == 'f' ||statusTc == 'b' || note != ''){ - tcNotes.value = tcNotes.value + '\nStep '+ row + ' ('+ statusTc+'):' + note ; - } - }) + var myRegexp = /step_row_(\d+)/g; + var stepresult = document.querySelectorAll('[id^=step_row_]'); + var tcNotes = document.getElementById('notes['+tcvID+']'); + stepresult.forEach(function(item){ + match = myRegexp.exec(item.id); + myRegexp.lastIndex = 0; + stepNum = document.getElementById('tcstep_'+match[1]); + var row = stepNum.innerHTML; + var note = ''; + var statusTc = '' + if ( item.getElementsByClassName('step_status').length > 0 ) + statusTc = item.getElementsByClassName('step_status')[0].value; + if ( item.getElementsByClassName('step_note_textarea').length > 0 ) + note = item.getElementsByClassName('step_note_textarea')[0].value; + if (statusTc == 'f' ||statusTc == 'b' || note != ''){ + tcNotes.value = tcNotes.value + '\nStep '+ row + ' ('+ statusTc+'):' + note ; + } + }) } if( goNext == undefined || goNext == 0 ) { jQuery('#save_results').val(1); diff --git a/gui/templates/tl-classic/execute/inc_exec_img_controls.tpl b/gui/templates/tl-classic/execute/inc_exec_img_controls.tpl index 553d62c757..aed72cfdfb 100644 --- a/gui/templates/tl-classic/execute/inc_exec_img_controls.tpl +++ b/gui/templates/tl-classic/execute/inc_exec_img_controls.tpl @@ -109,7 +109,7 @@ Author : franciscom   + onclick="javascript:saveExecStatus({$tcvID},'{$kode}',{$tlCfg->exec_cfg->steps_notes_concat});">  {/foreach}

@@ -121,7 +121,7 @@ Author : franciscom   + onclick="javascript:saveExecStatus({$tcvID},'{$kode}',{$tlCfg->exec_cfg->steps_notes_concat},1);">  {/foreach}