diff --git a/test/data/oauth.yaml b/test/data/oauth.yaml new file mode 100644 index 0000000000..700ff499a0 --- /dev/null +++ b/test/data/oauth.yaml @@ -0,0 +1,17 @@ +title: table zt_oauth +desc: "" +author: automated export +version: "1.0" +fields: + - field: account + fields: + - field: account1 + range: user + - field: account2 + range: 3-100 + - field: openID + range: 1-100 + - field: providerType + range: gitlab + - field: providerID + range: 1 diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index eb26a4b76b..97bbd5671a 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -20,7 +20,8 @@ $builder->team = array('rows' => 400, 'extends' => array('team')); $builder->build = array('rows' => 8, 'extends' => array('build')); $builder->release = array('rows' => 8, 'extends' => array('release')); -$builder->pipeline = array('rows' => 2, 'extends' => array('pipeline')); -$builder->repo = array('rows' => 1, 'extends' => array('repo')); -$builder->job = array('rows' => 2, 'extends' => array('job')); -$builder->mr = array('rows' => 1, 'extends' => array('mr')); +$builder->pipeline = array('rows' => 2, 'extends' => array('pipeline')); +$builder->repo = array('rows' => 1, 'extends' => array('repo')); +$builder->job = array('rows' => 2, 'extends' => array('job')); +$builder->mr = array('rows' => 1, 'extends' => array('mr')); +$builder->oauth = array('rows' => 90, 'extends' => array('oauth')); diff --git a/test/model/gitlab/checkuseraccess.php b/test/model/gitlab/checkuseraccess.php new file mode 100644 index 0000000000..51a6ec9c73 --- /dev/null +++ b/test/model/gitlab/checkuseraccess.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +loadModel('gitlab'); + +su('admin'); +$gitlabID = 1; +r($gitlab->checkUserAccess($gitlabID)) && p() && e('1'); //使用超级管理员判断权限 + +su('user57'); +$projectID = 0; +r($gitlab->checkUserAccess($gitlabID, $projectID)) && p() && e('0'); //切换普通用户,使用错误的项目ID判断权限 + +$projectID = 1582; +r($gitlab->checkUserAccess($gitlabID, $projectID)) && p() && e('0'); //切换普通用户,使用当前用户无身份的项目ID判断权限 + +$projectID = 1588; +r($gitlab->checkUserAccess($gitlabID, $projectID)) && p() && e('1'); //切换普通用户,使用当前用户是拥有者的项目ID判断权限 + +$project = new stdclass(); +$project->param = 'empty'; +r($gitlab->checkUserAccess($gitlabID, $projectID, $project)) && p() && e('0'); //切换普通用户,使用错误的项目信息判断权限是否有维护者权限 + +$project = $gitlab->apiGetSingleProject($gitlabID, $projectID); +r($gitlab->checkUserAccess($gitlabID, $projectID, $project)) && p() && e('1'); //切换普通用户,使用错误的项目信息判断权限是否有维护者权限 + +$projectID = 9; +r($gitlab->checkUserAccess($gitlabID, $projectID, null, array(), 'maintainer')) && p() && e('0'); //切换普通用户,使用当前用户是开发者的项目ID判断权限是否有维护者权限 + +r($gitlab->checkUserAccess($gitlabID, $projectID, $project, array(), 'maintainer')) && p() && e('1'); //切换普通用户,使用当前用户是拥有者的项目ID判断权限是否有维护者权限 diff --git a/test/model/gitlab/getgitlablistbyaccount.php b/test/model/gitlab/getgitlablistbyaccount.php new file mode 100644 index 0000000000..553f604877 --- /dev/null +++ b/test/model/gitlab/getgitlablistbyaccount.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +loadModel('gitlab'); + +r(count($gitlab->getGitLabListByAccount())) && p() && e('0'); //默认admin用户查询绑定的gitlab服务器 +r(count($gitlab->getGitLabListByAccount('user3'))) && p() && e('1'); //使用已绑定一个gitlab服务器的用户查询 +r(count($gitlab->getGitLabListByAccount('test1'))) && p() && e('0'); //使用未绑定gitlab服务器的用户查询 diff --git a/test/model/sonarqube/apigetqualitygate.php b/test/model/sonarqube/apigetqualitygate.php new file mode 100644 index 0000000000..6367fcea6a --- /dev/null +++ b/test/model/sonarqube/apigetqualitygate.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +loadModel('sonarqube'); + +$sonarqubeID = 0; +$projectKey = ''; +$result = $sonarqube->apiGetQualitygate($sonarqubeID, $projectKey); +if(empty($result)) $result = 'return empty'; +r($result) && p() && e('return empty'); //通过错误的sonarqubeID、projectKey,查询sonarqube质量门信息 + +$sonarqubeID = 2; +$projectKey = 'wrong_project'; +$result = $sonarqube->apiGetQualitygate($sonarqubeID, $projectKey); +r($result->errors) && p('0:msg') && e("Project 'wrong_project' not found"); //通过正确的sonarqubeID,不存在的projectKey查询sonarqube质量门信息 + +$projectKey = 'zentaopms'; +$result = $sonarqube->apiGetReport($sonarqubeID, $projectKey); +if(!empty($result->component)) $result = 'success'; +r($result) && p() && e("success"); //通过正确的sonarqubeID、projectKey查询sonarqube质量门信息 diff --git a/test/model/sonarqube/apigetreport.php b/test/model/sonarqube/apigetreport.php new file mode 100644 index 0000000000..250842676c --- /dev/null +++ b/test/model/sonarqube/apigetreport.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php +loadModel('sonarqube'); + +$sonarqubeID = 0; +$projectKey = ''; +$result = $sonarqube->apiGetReport($sonarqubeID, $projectKey); +if(empty($result)) $result = 'return empty'; +r($result) && p() && e('return empty'); //通过错误的sonarqubeID、projectKey,查询sonarqube报告 + +$sonarqubeID = 2; +$projectKey = 'wrong_project'; +$result = $sonarqube->apiGetReport($sonarqubeID, $projectKey); +r($result->errors) && p('0:msg') && e("Component key 'wrong_project' not found"); //通过正确的sonarqubeID,不存在的projectKey查询sonarqube报告 + +$projectKey = 'zentaopms'; +$metricKeys = 'wrong_params'; +$result = $sonarqube->apiGetReport($sonarqubeID, $projectKey, $metricKeys); +r($result->errors) && p('0:msg') && e("The following metric keys are not found: wrong_params"); //通过正确的sonarqubeID、projectKey,不正确的metricKeys查询sonarqube报告 + +$metricKeys = 'bugs'; +$result = $sonarqube->apiGetReport($sonarqubeID, $projectKey, $metricKeys); +if(!empty($result->component)) $result = 'success'; +r($result) && p() && e('success'); //通过正确的sonarqubeID、projectKey、metricKeys,查询sonarqube报告