From 9e45024d451eb800afde6dbece0759882db1e1d4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 4 Mar 2017 23:05:54 +0200 Subject: Add scenrio for Steven not being allowed to push --- 000.yarn | 32 +++++++++++++++++++++++++++++++- yarnhelper.py | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/000.yarn b/000.yarn index 008cba4..eb55f75 100644 --- a/000.yarn +++ b/000.yarn @@ -211,6 +211,20 @@ groups, and respositories. THEN ian can push qvarn FINALLY admin removes things that were created + SCENARIO Steven can clone Qvarn but not push changes + WHEN admin creates user steven + AND admin creates group qvarn-readers + AND admin adds steven to qvarn-readers + AND admin creates repository qvarn + AND admin sets qvarn config readers to qvarn-readers + AND admin sets qvarn config writers to qvarn-writers + THEN steven can clone qvarn + WHEN steven creates qvarn branch bugfix + AND steven changes qvarn branch bugfix + AND steven merges qvarn branch bugfix to master + THEN steven cannot push qvarn + FINALLY admin removes things that were created + SCENARIO everyone can clone a public repository WHEN admin creates repository qvarn AND admin sets qvarn config public to yes @@ -301,8 +315,24 @@ groups, and respositories. IMPLEMENTS THEN (\S+) can push (\S+) user = helper.get_next_match() repo = helper.get_next_match() + url = helper.repo_ssh_url(repo) dirname = helper.local_checkout_dirname(user, repo) - cliapp.runcmd(['git', 'push', '--all', 'origin'], cwd=dirname) + env = dict(os.environ) + env['GIT_SSH_COMMAND'] = helper.env_ssh_command(user) + cliapp.runcmd(['git', 'push', '--all', 'origin'], cwd=dirname, env=env) + + + IMPLEMENTS THEN (\S+) cannot push (\S+) + user = helper.get_next_match() + repo = helper.get_next_match() + dirname = helper.local_checkout_dirname(user, repo) + env = dict(os.environ) + env['GIT_SSH_COMMAND'] = helper.env_ssh_command(user) + exit, out, err = cliapp.runcmd_unchecked( + ['git', 'push', '--all', 'origin'], cwd=dirname, env=env) + sys.stdout.write(out) + sys.stderr.write(err) + helper.assertNotEqual(exit, 0) IMPLEMENTS WHEN (\S+) merges (\S+) branch (\S+) to (\S+) user = helper.get_next_match() diff --git a/yarnhelper.py b/yarnhelper.py index 7192b06..db2f9d3 100644 --- a/yarnhelper.py +++ b/yarnhelper.py @@ -142,7 +142,7 @@ class YarnHelper(object): return f.read() def ssh_key_file_for_user(self, user): # pragma: no cover - return '{}.key'.format(user) + return os.path.abspath('{}.key'.format(user)) def repo_ssh_url(self, repo): # pragma: no cover return 'ssh://git@{}/{}'.format(os.environ['GITANO_SERVER'], repo) -- cgit v1.2.1