* Delete test dir
This commit is contained in:
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
class gitlabTest
|
||||
{
|
||||
public $tester;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $tester;
|
||||
$this->tester = $tester;
|
||||
$this->gitlab = $this->tester->loadModel('gitlab');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getByID($id)
|
||||
{
|
||||
$gitlab = $this->gitlab->getByID($id);
|
||||
if(empty($gitlab)) return 0;
|
||||
return $gitlab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitlab list.
|
||||
*
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getList($orderBy = 'id_desc')
|
||||
{
|
||||
$gitlab = $this->gitlab->getList($orderBy);
|
||||
if(empty($gitlab)) return 0;
|
||||
return array_shift($gitlab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitlab pairs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPairs()
|
||||
{
|
||||
$pairs = $this->gitlab->getPairs();
|
||||
return key($pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitlab.
|
||||
*
|
||||
* @access public
|
||||
* @return object|string
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$gitlabID = $this->gitlab->create();
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
return key($errors);
|
||||
}
|
||||
|
||||
return $this->gitlab->getById($gitlabID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a gitlab.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object|string
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$this->gitlab->update($id);
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
return key($errors);
|
||||
}
|
||||
|
||||
return $this->gitlab->getById($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage branch privs.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param array $hasAccessBranches
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function manageBranchPrivsTest($gitlabID, $projectID, $hasAccessBranches = array())
|
||||
{
|
||||
$result = $this->gitlab->manageBranchPrivs($gitlabID, $projectID, $hasAccessBranches);
|
||||
return empty($result) ? 'success' : 'fail';
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage tag privs.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param array $hasAccessTags
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function manageTagPrivsTest($gitlabID, $projectID, $hasAccessTags = array())
|
||||
{
|
||||
$result = $this->gitlab->manageTagPrivs($gitlabID, $projectID, $hasAccessTags);
|
||||
return empty($result) ? 'success' : 'fail';
|
||||
}
|
||||
|
||||
/**
|
||||
* Api get signle tag.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $tag
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetSingleTagTest($gitlabID, $projectID, $tag)
|
||||
{
|
||||
return $this->gitlab->apiGetSingleTag($gitlabID, $projectID, $tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitlab menu.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getGitlabMenuTest($gitlabID, $type = 'project')
|
||||
{
|
||||
$html = $this->gitlab->getGitlabMenu($gitlabID, $type);
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
return key($errors);
|
||||
}
|
||||
|
||||
return substr($html, 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiCreateBranch();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,分支对象创建GitLab分支 >> return false
|
||||
使用空的gitlabID、projectID,正确的分支对象创建GitLab分支 >> return null
|
||||
使用正确的gitlabID、分支信息,错误的projectID创建分支 >> 404 Project Not Found
|
||||
通过gitlabID,projectID,分支对象正确创建GitLab分支 >> 1
|
||||
使用重复的分支信息创建分支 >> Branch already exists
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$branch = new stdclass();
|
||||
|
||||
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,分支对象创建GitLab分支
|
||||
|
||||
$branch->branch = 'test_branch17';
|
||||
$branch->ref = 'master';
|
||||
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
|
||||
if($result === null) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用空的gitlabID、projectID,正确的分支对象创建GitLab分支
|
||||
|
||||
$gitlabID = 1;
|
||||
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、分支信息,错误的projectID创建分支
|
||||
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
|
||||
if(!empty($result->name) and $result->name == $branch->branch) $result = true;
|
||||
if(!empty($result->message) and $result->message == 'Branch already exists') $result = true;
|
||||
r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('Branch already exists'); //使用重复的分支信息创建分支
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiCreateBranchPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,保护分支对象创建GitLab保护分支 >> return false
|
||||
使用空的gitlabID、projectID,正确的保护分支对象创建GitLab保护分支 >> return false
|
||||
使用正确的gitlabID、保护分支信息,错误的projectID创建保护分支 >> return false
|
||||
通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支 >> master
|
||||
使用重复的保护分支信息创建保护分支 >> Protected branch 'master' already exists
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$branch = new stdclass();
|
||||
|
||||
$result = $gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,保护分支对象创建GitLab保护分支
|
||||
|
||||
$branch->name = 'master';
|
||||
$branch->merge_access_level = '40';
|
||||
$branch->push_access_level = '40';
|
||||
$result = $gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的保护分支对象创建GitLab保护分支
|
||||
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、保护分支信息,错误的projectID创建保护分支
|
||||
|
||||
$projectID = 966;
|
||||
$gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch->name);
|
||||
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('name') && e('master'); //通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支
|
||||
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('message') && e("Protected branch 'master' already exists"); //使用重复的保护分支信息创建保护分支
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiCreateTagPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签 >> return false
|
||||
使用正确的gitlabID,空的projectID、保护标签对象创建GitLab保护标签 >> return false
|
||||
使用正确的gitlabID,空的保护标签信息,错误的projectID创建保护标签 >> return false
|
||||
使用正确的gitlabID、保护标签信息,错误的projectID创建保护标签 >> 404 Project Not Found
|
||||
使用正确的gitlabID、projectID、保护标签信息创建保护标签 >> test_tag1
|
||||
使用重复的保护标签信息创建保护标签 >> 名称已经被使用
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$tag = new stdclass();
|
||||
|
||||
$result = $gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签
|
||||
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID,空的projectID、保护标签对象创建GitLab保护标签
|
||||
|
||||
$projectID = 1;
|
||||
$result = $gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID,空的保护标签信息,错误的projectID创建保护标签
|
||||
|
||||
$tag->name = 'test_tag1';
|
||||
$tag->create_access_level = '40';
|
||||
r($gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag)) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、保护标签信息,错误的projectID创建保护标签
|
||||
|
||||
$projectID = 1555;
|
||||
$gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag->name);
|
||||
r($gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag)) && p('name') && e('test_tag1'); //使用正确的gitlabID、projectID、保护标签信息创建保护标签
|
||||
r($gitlab->apiCreateTagPriv($gitlabID, $projectID, $tag)) && p('message:0') && e("名称已经被使用"); //使用重复的保护标签信息创建保护标签
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiDeleteBranchPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,分支名称删除保护分支 >> return false
|
||||
使用正确的gitlabID、保护分支信息,错误的projectID删除保护分支 >> 404 Project Not Found
|
||||
通过gitlabID,projectID,分支名称正确删除保护分支 >> return true
|
||||
使用错误的保护分支信息删除保护分支 >> 404 Not found
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$branch = '';
|
||||
|
||||
$result = $gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,分支名称删除保护分支
|
||||
|
||||
$gitlabID = 1;
|
||||
$branch = 'master';
|
||||
$result = $gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、保护分支信息,错误的projectID删除保护分支
|
||||
|
||||
$projectID = 1565;
|
||||
$result = $gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch);
|
||||
if(!$result or substr($result->message, 0, 2) == '20') $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,分支名称正确删除保护分支
|
||||
|
||||
$branch = 'masters';
|
||||
$result = $gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('message') && e('404 Not found'); //使用错误的保护分支信息删除保护分支
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiDeleteTag();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,分支名称删除保护分支 >> return false
|
||||
使用正确的gitlabID、错误的projectID删除标签 >> 404 Project Not Found
|
||||
使用正确的gitlabID、projectID,不存在的标签删除 >> 404 Tag Not Found
|
||||
删除受保护的标签 >> Protected tags cannot be deleted
|
||||
成功删除标签 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$tagName = '';
|
||||
|
||||
$result = $gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,分支名称删除保护分支
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1;
|
||||
$tagName = 'testTagName';
|
||||
$result = $gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
r($result) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、错误的projectID删除标签
|
||||
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
r($result) && p('message') && e('404 Tag Not Found'); //使用正确的gitlabID、projectID,不存在的标签删除
|
||||
|
||||
$tagName = 'test_tag3';
|
||||
$result = $gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
r($result) && p('message') && e('Protected tags cannot be deleted'); //删除受保护的标签
|
||||
|
||||
$tagName = 'testTagName';
|
||||
$_POST['tag_name'] = $tagName;
|
||||
$_POST['ref'] = 'master';
|
||||
$gitlab->createTag($gitlabID, $projectID);
|
||||
$result = $gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
if(!$result or substr($result->message, 0, 2) == '20') $result = 'return true';
|
||||
r($result) && p('message') && e('return true'); //成功删除标签
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiDeleteTagPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,标签名称删除保护标签 >> return false
|
||||
使用正确的gitlabID、保护标签信息,错误的projectID删除保护标签 >> 404 Project Not Found
|
||||
使用错误的保护标签信息删除保护标签 >> 404 Not found
|
||||
通过gitlabID,projectID,标签名称正确删除保护标签 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$tag = '';
|
||||
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,标签名称删除保护标签
|
||||
|
||||
$gitlabID = 1;
|
||||
$tag = '2021/12/30';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
r($result) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、保护标签信息,错误的projectID删除保护标签
|
||||
|
||||
$projectID = 1552;
|
||||
$tag = 'masters';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
r($result) && p('message') && e('404 Not found'); //使用错误的保护标签信息删除保护标签
|
||||
|
||||
$projectID = 1555;
|
||||
$tag = 'test_tag1';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
if(!$result or substr($result->message, 0, 2) == '20') $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签名称正确删除保护标签
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetBranches();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过gitlabID,projectID,获取GitLab分支列表 >> 1
|
||||
通过gitlabID,projectID,获取GitLab分支数量 >> 1
|
||||
当前项目没有分支时,获取GitLab分支列表 >> 0
|
||||
当gitlabID存在,projectID不存在时,获取GitLab分支列表 >> return empty
|
||||
当gitlabID,projectID都为0时,获取GitLab分支列表 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
r(isset(array_shift($result)->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab分支列表
|
||||
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab分支数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 959;
|
||||
r(count($gitlab->apiGetBranches($gitlabID, $projectID))) && p() && e('0'); //当前项目没有分支时,获取GitLab分支列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID存在,projectID不存在时,获取GitLab分支列表
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab分支列表
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetBranchPrivs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取指定项目下受保护分支列表 >> master
|
||||
获取指定项目下受保护分支数量 >> 3
|
||||
获取无保护分支的项目下受保护分支数量 >> 0
|
||||
通过不存在projectID,获取受保护分支列表 >> 404 Project Not Found
|
||||
当gitlabID,projectID都为0时,获取受保护分支列表 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 961;
|
||||
$keyword = '';
|
||||
$orderBy = 'name_desc';
|
||||
$result = $gitlab->apiGetBranchPrivs($gitlabID, $projectID, $keyword, $orderBy);
|
||||
r($result) && p('master:name') && e('master'); //获取指定项目下受保护分支列表
|
||||
r(count($result)) && p() && e('3'); //获取指定项目下受保护分支数量
|
||||
|
||||
$projectID = 1572;
|
||||
r(count($gitlab->apiGetBranchPrivs($gitlabID, $projectID))) && p() && e('0'); //获取无保护分支的项目下受保护分支数量
|
||||
|
||||
$projectID = 0;
|
||||
r($gitlab->apiGetBranchPrivs($gitlabID, $projectID)) && p('message') && e('404 Project Not Found'); //通过不存在projectID,获取受保护分支列表
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetBranchPrivs($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取受保护分支列表
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetCurrentUser();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的数据获取用户信息 >> return false
|
||||
使用错误的host获取用户信息 >> return null
|
||||
使用正确的host,错误的token获取用户信息 >> 401 Unauthorized
|
||||
通过host,token获取用户信息 >> 1
|
||||
通过host,权限不足的token获取用户信息 >> insufficient_scope
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$host = '';
|
||||
$token = '';
|
||||
|
||||
$result = $gitlab->apiGetCurrentUser($host, $token);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的数据获取用户信息
|
||||
|
||||
$host = 'http://10.0.1.161:5108';
|
||||
$result = $gitlab->apiGetCurrentUser($host, $token);
|
||||
if(!$result) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用错误的host获取用户信息
|
||||
|
||||
$host = 'http://10.0.7.242:9980';
|
||||
$result = $gitlab->apiGetCurrentUser($host, $token);
|
||||
r($gitlab->apiGetCurrentUser($host, $token)) && p('message') && e('401 Unauthorized'); //使用正确的host,错误的token获取用户信息
|
||||
|
||||
$token = 'y2UBqwPPzaLxsniy8R6A';
|
||||
$result = $gitlab->apiGetCurrentUser($host, $token);
|
||||
r($result) && p('id') && e('1'); //通过host,token获取用户信息
|
||||
|
||||
$token = 'wVFHE6NZA-cJy-3U2y2J';
|
||||
$result = $gitlab->apiGetCurrentUser($host, $token);
|
||||
r($result) && p('error') && e('insufficient_scope'); //通过host,权限不足的token获取用户信息
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetGroupMembers();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的数据查询群组用户 >> return null
|
||||
使用空的groupID查询群组用户 >> return null
|
||||
使用错误的groupID查询群组用户 >> return null
|
||||
通过gitlabID,groupID查询群组用户 >> return true
|
||||
通过gitlabID,groupID,userID查询群组用户 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$groupID = 0;
|
||||
$userID = 0;
|
||||
|
||||
$result = $gitlab->apiGetGroupMembers($gitlabID, $groupID, $userID);
|
||||
if(!$result) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用空的数据查询群组用户
|
||||
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->apiGetGroupMembers($gitlabID, $groupID, $userID);
|
||||
if(!$result) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用空的groupID查询群组用户
|
||||
|
||||
$groupID = 1;
|
||||
$result = $gitlab->apiGetGroupMembers($gitlabID, $groupID, $userID);
|
||||
if(!$result) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用错误的groupID查询群组用户
|
||||
|
||||
$groupID = 2;
|
||||
$result = $gitlab->apiGetGroupMembers($gitlabID, $groupID, $userID);
|
||||
if(is_array($result)) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,groupID查询群组用户
|
||||
|
||||
$userID = 1;
|
||||
$result = $gitlab->apiGetGroupMembers($gitlabID, $groupID, $userID);
|
||||
if(is_array($result) && count($result) == 1) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,groupID,userID查询群组用户
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetGroups();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的数据查询群组 >> return null
|
||||
使用正确的gitlabID查询群组 >> return true
|
||||
使用错误的orderBy查询群组 >> return true
|
||||
通过gitlabID,orderBy查询群组 >> return true
|
||||
通过错误的minRole查询群组 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$orderBy = '';
|
||||
$minRole = '';
|
||||
|
||||
$result = $gitlab->apiGetGroups($gitlabID, $orderBy, $minRole);
|
||||
if(!$result) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用空的数据查询群组
|
||||
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->apiGetGroups($gitlabID, $orderBy, $minRole);
|
||||
if($result) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //使用正确的gitlabID查询群组
|
||||
|
||||
$orderBy = 'abc';
|
||||
$result = $gitlab->apiGetGroups($gitlabID, $orderBy, $minRole);
|
||||
if(is_array($result)) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //使用错误的orderBy查询群组
|
||||
|
||||
$orderBy = 'name_asc';
|
||||
$minRole = 'owner';
|
||||
$result = $gitlab->apiGetGroups($gitlabID, $orderBy, $minRole);
|
||||
if(is_array($result)) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,orderBy查询群组
|
||||
|
||||
$minRole = 'abc';
|
||||
$result = $gitlab->apiGetGroups($gitlabID, $orderBy, $minRole);
|
||||
if(is_array($result)) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过错误的minRole查询群组
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetSingleBranchPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,分支名称获取保护分支 >> return false
|
||||
使用正确的gitlabID、保护分支信息,错误的projectID获取保护分支 >> 404 Project Not Found
|
||||
通过gitlabID,projectID,分支名称正确获取保护分支 >> master
|
||||
使用错误的保护分支信息获取保护分支 >> 404 Not found
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$branch = '';
|
||||
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,分支名称获取保护分支
|
||||
|
||||
$gitlabID = 1;
|
||||
$branch = 'master';
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、保护分支信息,错误的projectID获取保护分支
|
||||
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('name') && e('master'); //通过gitlabID,projectID,分支名称正确获取保护分支
|
||||
|
||||
$branch = 'masters';
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('message') && e('404 Not found'); //使用错误的保护分支信息获取保护分支
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->apiGetSingleTag();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
查询正确的tag信息 >> 1230
|
||||
使用不存在的gitlabID查询tag信息 >> 0
|
||||
使用不存在的projectID查询tag信息 >> 404 Project Not Found
|
||||
使用不存在的tag名称查询tag信息 >> 404 Tag Not Found
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$tag1 = $gitlab->apiGetSingleTagTest(1, 1569, '1230');
|
||||
$tag2 = $gitlab->apiGetSingleTagTest(0, 1569, '1230');
|
||||
$tag3 = $gitlab->apiGetSingleTagTest(1, 0, '1230');
|
||||
$tag4 = $gitlab->apiGetSingleTagTest(1, 1569, '0');
|
||||
|
||||
r($tag1) && p('name') && e('1230'); // 查询正确的tag信息
|
||||
r($tag2) && p() && e('0'); // 使用不存在的gitlabID查询tag信息
|
||||
r($tag3) && p('message') && e('404 Project Not Found'); // 使用不存在的projectID查询tag信息
|
||||
r($tag4) && p('message') && e('404 Tag Not Found'); // 使用不存在的tag名称查询tag信息
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetTagPrivs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过gitlabID,projectID,获取GitLab标签保护列表 >> 1
|
||||
通过gitlabID,projectID,获取GitLab标签保护数量 >> 1
|
||||
当前项目没有标签保护时,获取GitLab标签保护列表 >> 0
|
||||
通过gitlabID,projectID,获取GitLab标签保护列表 >> return empty
|
||||
当gitlabID,projectID都为0时,获取GitLab标签保护列表 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetTagPrivs($gitlabID, $projectID);
|
||||
r(isset(array_shift($result)->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签保护列表
|
||||
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签保护数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1570;
|
||||
r(count($gitlab->apiGetTagPrivs($gitlabID, $projectID))) && p() && e('0'); //当前项目没有标签保护时,获取GitLab标签保护列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetTagPrivs($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p('') && e('return empty'); //通过gitlabID,projectID,获取GitLab标签保护列表
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetTagPrivs($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab标签保护列表
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetTags();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过gitlabID,projectID,获取GitLab标签列表 >> 1
|
||||
通过gitlabID,projectID,获取GitLab标签数量 >> 1
|
||||
当前项目没有标签时,获取GitLab标签列表 >> 0
|
||||
通过gitlabID,projectID,获取GitLab标签列表 >> return empty
|
||||
当gitlabID,projectID都为0时,获取GitLab标签列表 >> return empty
|
||||
通过gitlabID,projectID,按标签名升序获取GitLab标签列表 >> with_cicredentials
|
||||
通过gitlabID,projectID,搜索字符'zentaopms_15.2_20210720'获取GitLab标签列表 >> zentaopms_15.2_20210720
|
||||
通过gitlabID,projectID,每页20条记录,分页获取第二页GitLab标签列表 >> zentaopms_2.0_stable_20110503
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID);
|
||||
r(isset($result[0]->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签列表
|
||||
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1570;
|
||||
r(count($gitlab->apiGetTags($gitlabID, $projectID))) && p() && e('0'); //当前项目没有标签时,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p('') && e('return empty'); //通过gitlabID,projectID,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 964;
|
||||
$orderBy = 'name_asc';
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy);
|
||||
r($result) && p('0:name') && e('with_cicredentials'); //通过gitlabID,projectID,按标签名升序获取GitLab标签列表
|
||||
|
||||
$keyword = 'zentaopms_15.2_20210720';
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy, $keyword);
|
||||
r($result) && p('0:name') && e('zentaopms_15.2_20210720'); //通过gitlabID,projectID,搜索字符'zentaopms_15.2_20210720'获取GitLab标签列表
|
||||
|
||||
$tester->app->loadClass('pager', $static = true);
|
||||
$pager = new pager(0, 20, 2);
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy, '', $pager);
|
||||
r($result) && p('0:name') && e('zentaopms_2.0_stable_20110503'); //通过gitlabID,projectID,每页20条记录,分页获取第二页GitLab标签列表
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::checkAccessLevel();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的权限信息查询 >> 40
|
||||
使用只有维护者权限信息查询 >> 40
|
||||
使用包含维护者和开发者权限信息查询 >> 30
|
||||
使用包含禁止权限信息查询 >> 0
|
||||
使用包含禁止权限信息的二维数组查询 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$accessLevels = array();
|
||||
|
||||
$result = $gitlab->checkAccessLevel($accessLevels);
|
||||
r($result) && p() && e('40'); //使用空的权限信息查询
|
||||
|
||||
$accessLevels[0] = new stdClass();
|
||||
$accessLevels[0]->access_level = 40;
|
||||
$accessLevels[0]->access_level_description = 'Maintainers';
|
||||
r($gitlab->checkAccessLevel($accessLevels)) && p() && e('40'); //使用只有维护者权限信息查询
|
||||
|
||||
$accessLevels[1] = new stdClass();
|
||||
$accessLevels[1]->access_level = 30;
|
||||
$accessLevels[1]->access_level_description = 'Developers + Maintainers';
|
||||
r($gitlab->checkAccessLevel($accessLevels)) && p() && e('30'); //使用包含维护者和开发者权限信息查询
|
||||
|
||||
$accessLevels[2] = new stdClass();
|
||||
$accessLevels[2]->access_level = 0;
|
||||
$accessLevels[2]->access_level_description = 'No one';
|
||||
r($gitlab->checkAccessLevel($accessLevels)) && p() && e('0'); //使用包含禁止权限信息查询
|
||||
|
||||
$accessLevelArray = array(
|
||||
array(
|
||||
'access_level' => 40,
|
||||
'access_level_description' => 'Maintainers'
|
||||
),
|
||||
array(
|
||||
'access_level' => 0,
|
||||
'access_level_description' => 'No one'
|
||||
)
|
||||
);
|
||||
r($gitlab->checkAccessLevel($accessLevelArray)) && p() && e('0'); //使用包含禁止权限信息的二维数组查询
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::checkTokenAccess();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的数据验证token权限 >> return false
|
||||
使用错误的host验证token权限 >> return false
|
||||
使用正确的host,错误的token验证token权限 >> return null
|
||||
通过host,token验证token权限 >> success
|
||||
通过host,权限不足的token验证token权限 >> no access
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$host = '';
|
||||
$token = '';
|
||||
|
||||
$result = $gitlab->checkTokenAccess($host, $token);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的数据验证token权限
|
||||
|
||||
$host = 'http://10.0.1.161:5108';
|
||||
$result = $gitlab->checkTokenAccess($host, $token);
|
||||
if(!$result) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用错误的host验证token权限
|
||||
|
||||
$host = 'http://10.0.7.242:9980';
|
||||
$result = $gitlab->checkTokenAccess($host, $token);
|
||||
if(empty($result)) $result = 'return null';
|
||||
r($result) && p() && e('return null'); //使用正确的host,错误的token验证token权限
|
||||
|
||||
$token = 'x88fZokrp5hShia2jyBN';
|
||||
$result = $gitlab->checkTokenAccess($host, $token);
|
||||
if(isset($result->id)) $result = 'success';
|
||||
r($result) && p() && e('success'); //通过host,token验证token权限
|
||||
|
||||
$token = 'wVFHE6NZA-cJy-3U2y2J';
|
||||
$result = $gitlab->checkTokenAccess($host, $token);
|
||||
if(!isset($result->id)) $result = 'no access';
|
||||
r($result) && p() && e('no access'); //通过host,权限不足的token验证token权限
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::checkUserAccess();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用超级管理员判断权限 >> 1
|
||||
切换普通用户,使用错误的项目ID判断权限 >> 0
|
||||
切换普通用户,使用当前用户无身份的项目ID判断权限 >> 0
|
||||
切换普通用户,使用当前用户是拥有者的项目ID判断权限 >> 1
|
||||
切换普通用户,使用错误的项目信息判断权限是否有维护者权限 >> 0
|
||||
切换普通用户,使用错误的项目信息判断权限是否有维护者权限 >> 1
|
||||
切换普通用户,使用当前用户是开发者的项目ID判断权限是否有维护者权限 >> 0
|
||||
切换普通用户,使用当前用户是拥有者的项目ID判断权限是否有维护者权限 >> 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判断权限是否有维护者权限
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->create();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
GitLab名称为空 >> name
|
||||
服务器地址为空 >> url
|
||||
正确GitLab数据 >> GitLab,http://10.0.7.242:9980,1196c85ba525a268570df9da627e3a7b2d
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$_POST = array();
|
||||
$_POST['name'] = '';
|
||||
$_POST['url'] = 'http://10.0.7.242:9980';
|
||||
$_POST['token'] = 'y2UBqwPPzaLxsniy8R6A';
|
||||
$_POST['password'] = '';
|
||||
|
||||
r($gitlab->create()) && p() && e('name'); // GitLab名称为空
|
||||
|
||||
$_POST['name'] = 'GitLab';
|
||||
$_POST['url'] = '';
|
||||
r($gitlab->create()) && p() && e('url'); // 服务器地址为空
|
||||
|
||||
$_POST['url'] = 'http://10.0.7.242:9980';
|
||||
r($gitlab->create()) && p('name,url,token') && e('GitLab,http://10.0.7.242:9980,y2UBqwPPzaLxsniy8R6A'); // 正确GitLab数据
|
||||
|
||||
system("./ztest init");
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createBranch();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,分支对象创建GitLab分支 >> return false
|
||||
使用空的gitlabID、projectID,正确的分支对象创建GitLab分支 >> return false
|
||||
使用正确的gitlabID、分支信息,错误的projectID创建分支 >> return false
|
||||
通过gitlabID,projectID,分支对象正确创建GitLab分支 >> return true
|
||||
使用重复的分支信息创建分支 >> return false
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,分支对象创建GitLab分支
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['branch'] = 'test_branch17';
|
||||
$_POST['ref'] = 'master';
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的分支对象创建GitLab分支
|
||||
|
||||
dao::$errors = array();
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、分支信息,错误的projectID创建分支
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
|
||||
/* Delete branches with the same name. */
|
||||
$apiRoot = $gitlab->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/branches/{$_POST['branch']}");
|
||||
commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
|
||||
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用重复的分支信息创建分支
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createBranchPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,保护分支对象创建GitLab保护分支 >> return false
|
||||
使用空的gitlabID、projectID,正确的保护分支对象创建GitLab保护分支 >> return false
|
||||
使用正确的gitlabID、保护分支信息,错误的projectID创建保护分支 >> return false
|
||||
通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支 >> return true
|
||||
使用重复的保护分支信息创建保护分支 >> return false
|
||||
使用保护分支信息更新保护分支 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,保护分支对象创建GitLab保护分支
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['name'] = 'master';
|
||||
$_POST['merge_access_level'] = '40';
|
||||
$_POST['push_access_level'] = '40';
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的保护分支对象创建GitLab保护分支
|
||||
|
||||
dao::$errors = array();
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、保护分支信息,错误的projectID创建保护分支
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1565;
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支
|
||||
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用重复的保护分支信息创建保护分支
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['merge_access_level'] = '0';
|
||||
$result = $gitlab->createBranchPriv($gitlabID, $projectID, $branch = 'master');
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //使用保护分支信息更新保护分支
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createTag();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,标签对象创建GitLab标签 >> return false
|
||||
使用空的gitlabID、projectID,正确的标签对象创建GitLab标签 >> return false
|
||||
使用正确的gitlabID、标签信息,错误的projectID创建标签 >> return false
|
||||
通过gitlabID,projectID,标签对象正确创建GitLab标签 >> return true
|
||||
使用重复的标签信息创建标签 >> return false
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,标签对象创建GitLab标签
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['tag_name'] = 'test_tag17';
|
||||
$_POST['ref'] = 'master';
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的标签对象创建GitLab标签
|
||||
|
||||
dao::$errors = array();
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、标签信息,错误的projectID创建标签
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
|
||||
/* Delete tags with the same name. */
|
||||
$gitlab->apiDeleteTagPriv($gitlabID, $projectID, $_POST['tag_name']);
|
||||
$gitlab->apiDeleteTag($gitlabID, $projectID, $_POST['tag_name']);
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签对象正确创建GitLab标签
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用重复的标签信息创建标签
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createTagPriv();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签 >> 标签不能为空
|
||||
使用正确的保护标签对象,空的gitlabID、projectID创建GitLab保护标签 >> return false
|
||||
使用正确的gitlabID、保护标签信息,错误的projectID创建保护标签 >> 404 Project Not Found
|
||||
使用正确的gitlabID、projectID和保护标签信息创建保护标签 >> return true
|
||||
使用正确的gitlabID、projectID、保护标签信息,编辑保护标签 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$gitlab->createTagPriv($gitlabID, $projectID);
|
||||
r(dao::getError()) && p('name:0') && e('标签不能为空'); //使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签
|
||||
|
||||
$_POST['name'] = 'test_tag1';
|
||||
$_POST['create_access_level'] = '40';
|
||||
$result = $gitlab->createTagPriv($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的保护标签对象,空的gitlabID、projectID创建GitLab保护标签
|
||||
|
||||
dao::getError();
|
||||
$gitlabID = 1;
|
||||
$projectID = 1;
|
||||
$gitlab->createTagPriv($gitlabID, $projectID);
|
||||
r(dao::getError()[0]) && p() && e('404 Project Not Found'); //使用正确的gitlabID、保护标签信息,错误的projectID创建保护标签
|
||||
|
||||
$projectID = 1555;
|
||||
$gitlab->apiDeleteTagPriv($gitlabID, $projectID, $_POST['name']);
|
||||
$result = $gitlab->createTagPriv($gitlabID, $projectID);
|
||||
if(dao::getError() == false) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //使用正确的gitlabID、projectID和保护标签信息创建保护标签
|
||||
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createTagPriv($gitlabID, $projectID, $_POST['name']);
|
||||
if(dao::getError() == false) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //使用正确的gitlabID、projectID、保护标签信息,编辑保护标签
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->gitById();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用存在的ID >> 3
|
||||
使用空的ID >> 0
|
||||
使用不存在的ID >> 0
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
r($gitlab->getById($gitlabID)) && p('id') && e('1'); // 使用存在的ID
|
||||
|
||||
$gitlabID = 0;
|
||||
r($gitlab->getById($gitlabID)) && p() && e(0); // 使用空的ID
|
||||
|
||||
$gitlabID = 111;
|
||||
r($gitlab->getById($gitlabID)) && p() && e(0); // 使用不存在的ID
|
||||
|
||||
system("./ztest init");
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::getGitLabListByAccount();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
默认admin用户查询绑定的gitlab服务器 >> 0
|
||||
使用已绑定一个gitlab服务器的用户查询 >> 1
|
||||
使用未绑定gitlab服务器的用户查询 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$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服务器的用户查询
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->getGitlabMenu();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
打印gitlab用户的菜单 >> <div
|
||||
打印gitlab分组的菜单 >> <div
|
||||
打印gitlab项目的菜单 >> <div
|
||||
打印gitlab默认的菜单 >> <div
|
||||
打印gitlabID不存在的菜单 >> <div
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
r($gitlab->getGitlabMenuTest($gitlabID, 'user')) && p() && e('<div'); // 打印gitlab用户的菜单
|
||||
r($gitlab->getGitlabMenuTest($gitlabID, 'group')) && p() && e('<div'); // 打印gitlab分组的菜单
|
||||
r($gitlab->getGitlabMenuTest($gitlabID, 'project')) && p() && e('<div'); // 打印gitlab分组的菜单
|
||||
r($gitlab->getGitlabMenuTest($gitlabID)) && p() && e('<div'); // 打印gitlab默认的菜单
|
||||
|
||||
$gitlabID = 111;
|
||||
r($gitlab->getGitlabMenuTest($gitlabID)) && p() && e('<div'); // 使用不存在的ID
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->gitList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取GiLlab列表 >> 1
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$orderBy = 'id_desc';
|
||||
r($gitlab->getList($orderBy)) && p('id') && e('1'); // 获取GitLab列表
|
||||
|
||||
system("./ztest init");
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->gitPairs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取GitLab >> 1
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
r($gitlab->getPairs()) && p() && e('1'); // 获取GitLab
|
||||
|
||||
system("./ztest init");
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::getVersion();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过host,token检验api权限 >> success
|
||||
通过正确的host,错误的token获取api权限 >> return false
|
||||
通过错误或低版本的的host,token获取api权限 >> return false
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$gitlabServer = $tester->loadModel('pipeline')->getByID($gitlabID);
|
||||
|
||||
$result = $gitlab->getVersion($gitlabServer->url, $gitlabServer->token);
|
||||
if(isset($result->version)) $result = 'success';
|
||||
r($result) && p() && e('success'); //通过host,token检验api权限
|
||||
|
||||
$result = $gitlab->getVersion($gitlabServer->url, $gitlabServer->token . 'a');
|
||||
if(!isset($result->version)) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //通过正确的host,错误的token获取api权限
|
||||
|
||||
$result = $gitlab->getVersion($gitlabServer->url . '1', $gitlabServer->token);
|
||||
if(!isset($result->version)) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //通过错误或低版本的的host,token获取api权限
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->manageBranchPrivs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
维护已存在的保护分支 >> fail
|
||||
使用错误的gitlabID维护保护分支 >> success
|
||||
使用错误的项目ID维护保护分支 >> success
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$_POST['branches'][0] = '1227';
|
||||
$_POST['mergeLevels'][0] = 40;
|
||||
$_POST['pushLevels'][0] = 40;
|
||||
|
||||
$result1 = $gitlab->manageBranchPrivsTest(1, 1569);
|
||||
$result2 = $gitlab->manageBranchPrivsTest(0, 1569);
|
||||
$result3 = $gitlab->manageBranchPrivsTest(1, 0);
|
||||
|
||||
r($result1) && p('') && e('fail'); // 维护已存在的保护分支
|
||||
r($result2) && p('') && e('success'); // 使用错误的gitlabID维护保护分支
|
||||
r($result3) && p('') && e('success'); // 使用错误的项目ID维护保护分支
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->manageTagPrivs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
维护已存在的保护标签 >> fail
|
||||
使用错误的gitlabID维护保护标签 >> success
|
||||
使用错误的项目ID维护保护标签 >> success
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$_POST['tags'][0] = '1230';
|
||||
$_POST['createLevels'][0] = 40;
|
||||
|
||||
$result1 = $gitlab->manageTagPrivsTest(1, 1569);
|
||||
$result2 = $gitlab->manageTagPrivsTest(0, 1569);
|
||||
$result3 = $gitlab->manageTagPrivsTest(1, 0);
|
||||
|
||||
r($result1) && p('') && e('fail'); // 维护正常的保护标签
|
||||
r($result2) && p('') && e('success'); // 使用错误的gitlabID维护保护标签
|
||||
r($result3) && p('') && e('success'); // 使用错误的项目ID维护保护标签
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->update();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
GitLab名称为空 >> name
|
||||
服务器地址为空 >> url
|
||||
正确GitLab数据 >> Changed GitLab
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$gitlabID = 3;
|
||||
|
||||
$_POST = array();
|
||||
$_POST['name'] = '';
|
||||
$_POST['url'] = 'http://10.0.7.242:9980';
|
||||
$_POST['account'] = 'admin';
|
||||
$_POST['token'] = 'y2UBqwPPzaLxsniy8R6A';
|
||||
$_POST['password'] = '';
|
||||
|
||||
r($gitlab->update($gitlabID)) && p() && e('name'); // GitLab名称为空
|
||||
|
||||
$_POST['name'] = 'Changed GitLab';
|
||||
$_POST['url'] = '';
|
||||
r($gitlab->update($gitlabID)) && p() && e('url'); // 服务器地址为空
|
||||
|
||||
$_POST['url'] = 'http://10.0.7.242:9980';
|
||||
r($gitlab->update($gitlabID)) && p('name') && e('Changed GitLab'); // 正确GitLab数据
|
||||
|
||||
system("./ztest init");
|
||||
Reference in New Issue
Block a user