本文整理汇总了Python中pysflib.sfgerrit.GerritUtils类的典型用法代码示例。如果您正苦于以下问题:Python GerritUtils类的具体用法?Python GerritUtils怎么用?Python GerritUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GerritUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _prepare_review_submit_testing
def _prepare_review_submit_testing(self, project_options=None):
if project_options is None:
u2mail = config.USERS[config.USER_2]['email']
project_options = {'core-group': u2mail}
pname = 'p_%s' % create_random_str()
self.create_project(pname, project_options)
un = config.ADMIN_USER
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[un]['auth_cookie'])
k_index = gu.add_pubkey(config.USERS[un]["pubkey"])
self.assertTrue(gu.project_exists(pname))
priv_key_path = set_private_key(config.USERS[un]["privkey"])
gitu = GerritGitUtils(un,
priv_key_path,
config.USERS[un]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (un, config.GATEWAY_HOST,
pname)
clone_dir = gitu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
gitu.add_commit_and_publish(clone_dir, "master", "Test commit")
change_ids = gu.get_my_changes_for_project(pname)
self.assertEqual(len(change_ids), 1)
change_id = change_ids[0]
return change_id, gu, k_index
开发者ID:earlren1014,项目名称:RedHat-Software-Factory,代码行数:28,代码来源:test_gerrit.py
示例2: setUp
def setUp(self):
self.msu = ManageSfUtils(config.GATEWAY_URL)
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.k_idx = self.gu2.add_pubkey(config.USERS[config.USER_2]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Configuration to access mirror repo present in mysql
self.msql_repo_path = "ssh://%[email protected]%s/%s" \
% (config.GERRIT_USER, config.GATEWAY_HOST,
'home/gerrit/site_path/git/')
# prepare environment for git clone on mirror repo
self.mt = Tool()
self.mt_tempdir = tempfile.mkdtemp()
priv_key = file(config.GERRIT_SERVICE_PRIV_KEY_PATH, 'r').read()
priv_key_path = os.path.join(self.mt_tempdir, 'user.priv')
file(priv_key_path, 'w').write(priv_key)
os.chmod(priv_key_path, stat.S_IREAD | stat.S_IWRITE)
ssh_wrapper = "ssh -o StrictHostKeyChecking=no -i " \
"%s \"[email protected]\"" % priv_key_path
wrapper_path = os.path.join(self.mt_tempdir, 'ssh_wrapper.sh')
file(wrapper_path, 'w').write(ssh_wrapper)
os.chmod(wrapper_path, stat.S_IRWXU)
self.mt.env['GIT_SSH'] = wrapper_path
self.pname = 'test-replication'
开发者ID:danielmellado,项目名称:software-factory,代码行数:32,代码来源:test_replication.py
示例3: test_create_public_project_as_user_clone_as_user
def test_create_public_project_as_user_clone_as_user(self):
""" Create public project as user then clone as user
"""
pname = 'p_%s' % create_random_str()
# create the project as admin
self.create_project(pname, config.USER_2)
# add user2 ssh pubkey to user2
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
gu.add_pubkey(config.USER_2_PUB_KEY)
# prepare to clone
priv_key_path = set_private_key(config.USER_2_PRIV_KEY)
self.dirs_to_delete.append(os.path.dirname(priv_key_path))
ggu = GerritGitUtils(config.USER_2,
priv_key_path,
config.USERS[config.USER_2]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.USER_2,
config.GATEWAY_HOST, pname)
# clone
clone_dir = ggu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Verify master own the .gitreview file
self.assertTrue(os.path.isfile(os.path.join(clone_dir,
'.gitreview')))
开发者ID:invenfantasy,项目名称:software-factory,代码行数:27,代码来源:test_01_managesf.py
示例4: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.ju = JenkinsUtils()
self.gu.add_pubkey(config.USERS[self.un]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Clone the config repo and make change to it
# in order to test the new sample_project
self.config_clone_dir = self.clone_as_admin("config")
self.original_layout = file(os.path.join(
self.config_clone_dir, "zuul/layout.yaml")).read()
self.original_zuul_projects = file(os.path.join(
self.config_clone_dir, "zuul/projects.yaml")).read()
self.original_project = file(os.path.join(
self.config_clone_dir, "jobs/projects.yaml")).read()
# Put USER_2 as core for config project
self.gu.add_group_member(config.USER_2, "config-core")
开发者ID:basejumpa,项目名称:software-factory,代码行数:27,代码来源:test_project_test.py
示例5: test_plugins_installed
def test_plugins_installed(self):
""" Test if plugins are present
"""
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
plugins = gu.list_plugins()
self.assertIn('download-commands', plugins)
self.assertIn('avatars-gravatar', plugins)
self.assertIn('reviewers-by-blame', plugins)
开发者ID:earlren1014,项目名称:RedHat-Software-Factory,代码行数:10,代码来源:test_gerrit.py
示例6: test_plugins_installed
def test_plugins_installed(self):
""" Test if plugins are present
"""
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
plugins = gu.list_plugins()
self.assertIn('download-commands', plugins)
self.assertIn('gravatar-avatar-provider', plugins)
self.assertIn('reviewers-by-blame', plugins)
开发者ID:invenfantasy,项目名称:software-factory,代码行数:10,代码来源:test_02_gerrit.py
示例7: test_check_config_repo_exists
def test_check_config_repo_exists(self):
""" Validate config repo has been bootstraped
"""
pname = "config"
gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"])
self.assertTrue(gu.project_exists(pname))
ggu = GerritGitUtils(config.ADMIN_USER, config.ADMIN_PRIV_KEY_PATH, config.USERS[config.ADMIN_USER]["email"])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER, config.GATEWAY_HOST, pname)
clone_dir = ggu.clone(url, pname)
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Check if the clone dir has projects file
self.assertTrue(os.path.isfile(os.path.join(clone_dir, "jobs/projects.yaml")))
开发者ID:pabelanger,项目名称:software-factory,代码行数:14,代码来源:test_configrepo.py
示例8: setUp
def setUp(self):
self.projects = []
self.rm = get_issue_tracker_utils(
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
开发者ID:snowsky,项目名称:software-factory,代码行数:7,代码来源:test_userdata.py
示例9: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.rm = RedmineUtils(
config.GATEWAY_URL + "/redmine/", auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"]
)
self.gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"])
开发者ID:pabelanger,项目名称:software-factory,代码行数:7,代码来源:test_managesf.py
示例10: setUp
def setUp(self):
self.projects = []
self.rm = RedmineUtils(
config.REDMINE_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
开发者ID:invenfantasy,项目名称:software-factory,代码行数:8,代码来源:test_11_project_membership.py
示例11: test_review_labels
def test_review_labels(self):
""" Test if list of review labels are as expected
"""
pname = 'p_%s' % create_random_str()
self.create_project(pname)
un = config.ADMIN_USER
gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[un]['auth_cookie'])
k_index = gu.add_pubkey(config.USERS[un]["pubkey"])
self.assertTrue(gu.project_exists(pname))
priv_key_path = set_private_key(config.USERS[un]["privkey"])
gitu = GerritGitUtils(un,
priv_key_path,
config.USERS[un]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (un, config.GATEWAY_HOST,
pname)
clone_dir = gitu.clone(url, pname)
self.dirs_to_delete.append(os.path.dirname(clone_dir))
gitu.add_commit_and_publish(clone_dir, "master", "Test commit")
change_ids = gu.get_my_changes_for_project(pname)
self.assertEqual(len(change_ids), 1)
change_id = change_ids[0]
labels = gu.get_labels_list_for_change(change_id)
self.assertIn('Workflow', labels)
self.assertIn('Code-Review', labels)
self.assertIn('Verified', labels)
self.assertEqual(len(labels.keys()), 3)
gu.del_pubkey(k_index)
开发者ID:earlren1014,项目名称:RedHat-Software-Factory,代码行数:34,代码来源:test_gerrit.py
示例12: test_check_config_repo_exists
def test_check_config_repo_exists(self):
pname = 'config'
gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.assertTrue(gu.project_exists(pname))
ggu = GerritGitUtils(config.ADMIN_USER,
config.ADMIN_PRIV_KEY_PATH,
config.USERS[config.ADMIN_USER]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER,
config.GATEWAY_HOST, pname)
clone_dir = ggu.clone(url, pname)
# Test that the clone is a success
self.assertTrue(os.path.isdir(clone_dir))
# Check if the clone dir has projects file
self.assertTrue(os.path.isfile(os.path.join(clone_dir,
"jobs/projects.yaml")))
开发者ID:invenfantasy,项目名称:software-factory,代码行数:18,代码来源:test_04_configrepo.py
示例13: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.issues = []
self.u = config.ADMIN_USER
self.u2 = config.USER_2
self.rm = get_issue_tracker_utils(
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u2]['auth_cookie'])
self.gu.add_pubkey(config.USERS[self.u]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.u]["privkey"])
self.gitu = GerritGitUtils(self.u,
priv_key_path,
config.USERS[self.u]['email'])
开发者ID:basejumpa,项目名称:software-factory,代码行数:19,代码来源:test_commit_hooks.py
示例14: setUp
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.issues = []
self.u = config.ADMIN_USER
self.u2 = config.USER_2
self.rm = RedmineUtils(
config.REDMINE_URL,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[self.u]['auth_cookie'])
self.gu2 = GerritUtils(
'https://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[self.u2]['auth_cookie'])
self.gu.add_pubkey(config.USERS[self.u]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.u]["privkey"])
self.gitu = GerritGitUtils(self.u,
priv_key_path,
config.USERS[self.u]['email'])
开发者ID:invenfantasy,项目名称:software-factory,代码行数:20,代码来源:test_08_commit_hooks.py
示例15: test_gerrit_api_accessible
def test_gerrit_api_accessible(self):
""" Test if Gerrit API is accessible on gateway hosts
"""
m = ManageSfUtils(config.GATEWAY_URL)
url = config.GATEWAY_URL + "/api/"
a = GerritUtils(url)
a.g.url = "%s/" % a.g.url.rstrip('a/')
self.assertRaises(HTTPError, a.get_account, config.USER_1)
api_passwd = m.create_gerrit_api_password(config.USER_1)
auth = HTTPBasicAuth(config.USER_1, api_passwd)
a = GerritUtils(url, auth=auth)
self.assertTrue(a.get_account(config.USER_1))
m.delete_gerrit_api_password(config.USER_1)
a = GerritUtils(url, auth=auth)
self.assertRaises(HTTPError, a.get_account, config.USER_1)
a = GerritUtils(url)
a.g.url = "%s/" % a.g.url.rstrip('a/')
self.assertRaises(HTTPError, a.get_account, 'john')
开发者ID:mscherer,项目名称:software-factory,代码行数:22,代码来源:test_gateway.py
示例16: __init__
def __init__(self):
with open("%s/resources.yaml" % pwd, 'r') as rsc:
self.resources = yaml.load(rsc)
config.USERS[config.ADMIN_USER]['auth_cookie'] = get_cookie(
config.ADMIN_USER, config.USERS[config.ADMIN_USER]['password'])
self.gu = GerritUtils(
'http://%s/' % config.GATEWAY_HOST,
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.ggu = GerritGitUtils(config.ADMIN_USER,
config.ADMIN_PRIV_KEY_PATH,
config.USERS[config.ADMIN_USER]['email'])
self.ju = JenkinsUtils()
self.rm = RedmineUtils(
config.GATEWAY_URL + "/redmine/",
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
开发者ID:basejumpa,项目名称:software-factory,代码行数:15,代码来源:checker.py
示例17: setUp
def setUp(self):
self.msu = ManageSfUtils(config.GATEWAY_URL)
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.k_idx = self.gu2.add_pubkey(config.USERS[config.USER_2]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Prepare environment for git clone on mirror repo
self.mt = Tool()
self.mt_tempdir = tempfile.mkdtemp()
# Copy the service private key in a flat file
priv_key = file(config.SERVICE_PRIV_KEY_PATH, 'r').read()
priv_key_path = os.path.join(self.mt_tempdir, 'user.priv')
file(priv_key_path, 'w').write(priv_key)
os.chmod(priv_key_path, stat.S_IREAD | stat.S_IWRITE)
# Prepare the ssh wrapper script
ssh_wrapper = "ssh -o StrictHostKeyChecking=no -i %s \"[email protected]\"" % (
priv_key_path)
wrapper_path = os.path.join(self.mt_tempdir, 'ssh_wrapper.sh')
file(wrapper_path, 'w').write(ssh_wrapper)
os.chmod(wrapper_path, stat.S_IRWXU)
# Set the wrapper as GIT_SSH env variable
self.mt.env['GIT_SSH'] = wrapper_path
self.config_clone_dir = None
# Project we are going to configure the replication for
self.pname = 'test/replication'
# Remove artifacts of previous run if any
self.delete_config_section(self.un, self.pname)
self.delete_mirror_repo(self.pname)
开发者ID:basejumpa,项目名称:software-factory,代码行数:40,代码来源:test_replication.py
示例18: TestGerritHooks
class TestGerritHooks(Base):
""" Functional tests that validate Gerrit hooks.
"""
@classmethod
def setUpClass(cls):
cls.msu = ManageSfUtils(config.GATEWAY_URL)
@classmethod
def tearDownClass(cls):
pass
def setUp(self):
self.projects = []
self.dirs_to_delete = []
self.issues = []
self.u = config.ADMIN_USER
self.u2 = config.USER_2
self.rm = RedmineUtils(
config.GATEWAY_URL + "/redmine/",
auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.u2]['auth_cookie'])
self.gu.add_pubkey(config.USERS[self.u]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.u]["privkey"])
self.gitu = GerritGitUtils(self.u,
priv_key_path,
config.USERS[self.u]['email'])
def tearDown(self):
for issue in self.issues:
self.rm.delete_issue(issue)
for name in self.projects:
self.msu.deleteProject(name, self.u)
for dirs in self.dirs_to_delete:
shutil.rmtree(dirs)
def create_project(self, name, user,
options=None):
self.msu.createProject(name, user,
options)
self.projects.append(name)
def _test_update_issue_hooks(self, comment_template, status):
""" A referenced issue in commit msg triggers the hook
"""
pname = 'p_%s' % create_random_str()
# Be sure the project does not exist
self.msu.deleteProject(pname, self.u)
# Create the project
self.create_project(pname, self.u)
# Put USER_2 as core for the project
self.gu.add_group_member(self.u2, "%s-core" % pname)
# Create an issue on the project
issue_id = self.rm.create_issue(pname, "There is a problem")
# Clone and commit something
url = "ssh://%[email protected]%s:29418/%s" % (self.u, config.GATEWAY_HOST,
pname)
clone_dir = self.gitu.clone(url, pname)
cmt_msg = comment_template % issue_id
self.gitu.add_commit_and_publish(clone_dir, 'master', cmt_msg)
# Check issue status (Gerrit hook updates the issue to in progress)
attempt = 0
while True:
if self.rm.test_issue_status(issue_id, 'In Progress'):
break
if attempt > 10:
break
time.sleep(1)
attempt += 1
self.assertTrue(self.rm.test_issue_status(issue_id, 'In Progress'))
self._test_merging(pname, issue_id, status)
def _test_merging(self, pname, issue_id, status):
# Get the change id and merge the patch
change_ids = self.gu.get_my_changes_for_project(pname)
self.assertGreater(len(change_ids), 0)
change_id = change_ids[0]
self.gu.submit_change_note(change_id, "current", "Code-Review", "2")
self.gu.submit_change_note(change_id, "current", "Workflow", "1")
self.gu.submit_change_note(change_id, "current", "Verified", "2")
self.gu2.submit_change_note(change_id, "current", "Code-Review", "2")
self.assertTrue(self.gu.submit_patch(change_id, "current"))
# Check issue status (Gerrit hook updates the issue to in progress)
attempt = 0
while True:
if self.rm.test_issue_status(issue_id, status):
break
if attempt > 10:
break
time.sleep(1)
#.........这里部分代码省略.........
开发者ID:danielmellado,项目名称:software-factory,代码行数:101,代码来源:test_commit_hooks.py
示例19: TestProjectMembership
class TestProjectMembership(Base):
""" Functional tests that validate adding or deleting
users to project groups using managesf.
"""
@classmethod
def setUpClass(cls):
cls.msu = ManageSfUtils(config.GATEWAY_URL)
@classmethod
def tearDownClass(cls):
pass
def setUp(self):
self.projects = []
self.rm = RedmineUtils(
config.GATEWAY_URL + "/redmine/", auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"]
)
self.gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]["auth_cookie"])
def tearDown(self):
for name in self.projects:
self.msu.deleteProject(name, config.ADMIN_USER)
def create_project(self, name, user, options=None):
self.msu.createProject(name, user, options)
self.projects.append(name)
def test_admin_manage_project_members(self):
""" Test admin can add and delete users from all project groups
"""
pname = "p_%s" % create_random_str()
self.create_project(pname, config.ADMIN_USER)
# Gerrit part
self.assertTrue(self.gu.project_exists(pname))
self.assertTrue(self.gu.group_exists("%s-ptl" % pname))
self.assertTrue(self.gu.group_exists("%s-core" % pname))
groups = "ptl-group core-group"
# Add user2 to ptl and core groups
self.msu.addUsertoProjectGroups(config.ADMIN_USER, pname, config.USER_2, groups)
# Test if user2 exists in ptl and core groups
self.assertTrue(self.gu.member_in_group(config.USER_2, "%s-ptl" % pname))
self.assertTrue(self.gu.member_in_group(config.USER_2, "%s-core" % pname))
# Redmine part
self.assertTrue(self.rm.check_user_role(pname, config.USER_2, "Manager"))
self.assertTrue(self.rm.check_user_role(pname, config.USER_2, "Developer"))
# Delete user2 from project groups
self.msu.deleteUserFromProjectGroups(config.ADMIN_USER, pname, config.USER_2)
# Test if user exists in ptl and core groups
self.assertFalse(self.gu.member_in_group(config.USER_2, "%s-ptl" % pname))
self.assertFalse(self.gu.member_in_group(config.USER_2, "%s-core" % pname))
# Redmine part
self.assertFalse(self.rm.check_user_role(pname, config.USER_2, "Manager"))
self.assertFalse(self.rm.check_user_role(pname, config.USER_2, "Developer"))
def test_ptl_manage_project_members(self):
""" Test ptl can add and delete users from all project groups
"""
# Let user2 create the project, so he will be ptl for this project
pname = "p_%s" % create_random_str()
self.create_project(pname, config.USER_2)
# Gerrit part
self.assertTrue(self.gu.project_exists(pname))
self.assertTrue(self.gu.group_exists("%s-ptl" % pname))
self.assertTrue(self.gu.group_exists("%s-core" % pname))
groups = "ptl-group core-group"
# ptl should be ale to add users to all groups
# so user2 should be able to add user3 to ptl and core groups
self.msu.addUsertoProjectGroups(config.USER_2, pname, config.USER_3, groups)
# Test if user3 exists in ptl and core groups
self.assertTrue(self.gu.member_in_group(config.USER_3, "%s-ptl" % pname))
self.assertTrue(self.gu.member_in_group(config.USER_3, "%s-core" % pname))
# Redmine part
self.assertTrue(self.rm.check_user_role(pname, config.USER_3, "Manager"))
self.assertTrue(self.rm.check_user_role(pname, config.USER_3, "Developer"))
# ptl should be able to remove users from all groups
self.msu.deleteUserFromProjectGroups(config.USER_2, pname, config.USER_3)
# user3 shouldn't exist in any group
self.assertFalse(self.gu.member_in_group(config.USER_3, "%s-ptl" % pname))
self.assertFalse(self.gu.member_in_group(config.USER_3, "%s-core" % pname))
# Redmine part
self.assertFalse(self.rm.check_user_role(pname, config.USER_3, "Manager"))
self.assertFalse(self.rm.check_user_role(pname, config.USER_3, "Developer"))
def test_core_manage_project_members(self):
""" Test core can add and delete users to core group
"""
# let admin create the project
pname = "p_%s" % create_random_str()
self.create_project(pname, config.ADMIN_USER)
# Gerrit part
self.assertTrue(self.gu.project_exists(pname))
self.assertTrue(self.gu.group_exists("%s-ptl" % pname))
self.assertTrue(self.gu.group_exists("%s-core" % pname))
groups = "core-group"
# Add user2 as core user
#.........这里部分代码省略.........
开发者ID:danielmellado,项目名称:software-factory,代码行数:101,代码来源:test_project_membership.py
示例20: TestProjectReplication
class TestProjectReplication(Base):
""" Functional tests to verify the gerrit replication feature
"""
def setUp(self):
self.msu = ManageSfUtils(config.GATEWAY_URL)
self.un = config.ADMIN_USER
self.gu = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[self.un]['auth_cookie'])
self.gu2 = GerritUtils(
config.GATEWAY_URL,
auth_cookie=config.USERS[config.USER_2]['auth_cookie'])
self.k_idx = self.gu2.add_pubkey(config.USERS[config.USER_2]["pubkey"])
priv_key_path = set_private_key(config.USERS[self.un]["privkey"])
self.gitu_admin = GerritGitUtils(self.un,
priv_key_path,
config.USERS[self.un]['email'])
# Configuration to access mirror repo present in mysql
self.msql_repo_path = "ssh://%[email protected]%s/%s" \
% (config.GERRIT_USER, config.GATEWAY_HOST,
'home/gerrit/site_path/git/')
# prepare environment for git clone on mirror repo
self.mt = Tool()
self.mt_tempdir = tempfile.mkdtemp()
priv_key = file(config.GERRIT_SERVICE_PRIV_KEY_PATH, 'r').read()
priv_key_path = os.path.join(self.mt_tempdir, 'user.priv')
file(priv_key_path, 'w').write(priv_key)
os.chmod(priv_key_path, stat.S_IREAD | stat.S_IWRITE)
ssh_wrapper = "ssh -o StrictHostKeyChecking=no -i " \
"%s \"[email protected]\"" % priv_key_path
wrapper_path = os.path.join(self.mt_tempdir, 'ssh_wrapper.sh')
file(wrapper_path, 'w').write(ssh_wrapper)
os.chmod(wrapper_path, stat.S_IRWXU)
self.mt.env['GIT_SSH'] = wrapper_path
self.pname = 'test-replication'
def tearDown(self):
self.deleteConfigSection(self.un, self.pname)
self.deleteMirrorRepo(self.pname)
self.msu.deleteProject(self.pname, self.un)
self.gu2.del_pubkey(self.k_idx)
# Can't use GerritGitUtils.clone as not sure when source uri repo in mysql
# be ready.(i.e gerrit is taking time to create the mirror repo in mysql
# node) So this clone may succeed or fail, we don't need 'git review -s'
# and other review commands in clone method
def clone(self, uri, target):
self.assertTrue(uri.startswith('ssh://'))
cmd = "git clone %s %s" % (uri, target)
self.mt.exe(cmd, self.mt_tempdir)
clone = os.path.join(self.mt_tempdir, target)
return clone
def create_project(self, name, user, options=None):
self.msu.createProject(name, user, options)
def ssh_run_cmd(self, sshkey_priv_path, user, host, subcmd):
host = '%[email protected]%s' % (user, host)
sshcmd = ['ssh', '-o', 'LogLevel=ERROR',
'-o', 'StrictHostKeyChecking=no',
'-o', 'UserKnownHostsFile=/dev/null', '-i',
sshkey_priv_path, host]
cmd = sshcmd + subcmd
p = Popen(cmd, stdout=PIPE)
return p.communicate()
def deleteMirrorRepo(self, name):
sshkey_priv_path = config.GERRIT_SERVICE_PRIV_KEY_PATH
user = 'gerrit'
host = config.GATEWAY_HOST
mirror_path = '/home/gerrit/site_path/git/%s.git' % name
cmd = ['rm', '-rf', mirror_path]
self.ssh_run_cmd(sshkey_priv_path, user, host, cmd)
def createConfigSection(self, user, project):
# Section name will be node name and the project
section = 'mysql_%s' % project
host = '%[email protected]%s' % (config.GERRIT_USER, config.GATEWAY_HOST)
mirror_repo_path = '/home/gerrit/site_path/git/\${name}.git'
url = '%s:%s' % (host, mirror_repo_path)
self.msu.replicationModifyConfig(user, 'add', section,
'projects', project)
self.msu.replicationModifyConfig(user, 'add',
section, 'url', url)
push = '+refs/heads/*:refs/heads/*'
self.msu.replicationModifyConfig(user, 'add',
section, 'push', push)
push = '+refs/tags/*:refs/tags/*'
self.msu.replicationModifyConfig(user, 'add',
section, 'push', push)
def deleteConfigSection(self, user, project):
# section name will be node name and the project
section = 'managesf_%s' % project
self.msu.replicationModifyConfig(user, 'remove-section', section)
def mirror_clone_and_check_files(self, url, pname, us_files):
retries = 0
files = []
#.........这里部分代码省略.........
开发者ID:danielmellado,项目名称:software-factory,代码行数:101,代码来源:test_replication.py
注:本文中的pysflib.sfgerrit.GerritUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论