* Add unit cases.
This commit is contained in:
@@ -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
|
||||
@@ -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'));
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::checkUserAccess();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->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判断权限是否有维护者权限
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::getGitLabListByAccount();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->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服务器的用户查询
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiGetQualitygate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->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质量门信息
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiGetReport();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->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报告
|
||||
Reference in New Issue
Block a user