From b1f1d3bfa87fcba497bcd2e15ff6dab70123adbe Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Tue, 18 Feb 2014 15:01:47 +0000 Subject: Add https push test --- test.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index a79ccd0..c869038 100755 --- a/test.py +++ b/test.py @@ -48,6 +48,19 @@ def create_test_project(url, project): 'Users with read access to ' + project]) remote_runcmd(url, ['group', 'addgroup', t('readers'), t('writers')]) +def delete_repo(trove_id, project, repo): + output = subprocess.check_output(['ssh', 'git@%s' % trove_id, + 'destroy', '%s/%s/%s' % (trove_id, project, repo)], + stderr=subprocess.STDOUT) + + # The destroy command gives us back a token, + # we send the same command back with the token, + # to confirm we really want to delete the repo + token = output.split()[-1] + + subprocess.check_output(['ssh', 'git@ct-ri-4', 'destroy', + '%s/%s/%s' % (trove_id, project, repo), token]) + def create_test_repo(remote_url, project, repo): trove_id = 'ct-ri-4' #self.vm_nhame @@ -57,23 +70,25 @@ def create_test_repo(remote_url, project, repo): def can_clone(url, env=None): workspace_dir = tempfile.mkdtemp() - run_git(['clone', url], workspace_dir, env) + run_git(['clone', url], workspace_dir, env=env) shutil.rmtree(workspace_dir) -def can_push(url, repo): +def can_push(url, repo, env=None): workspace_dir = tempfile.mkdtemp() repodir = os.path.join(workspace_dir, repo) - run_git(['clone', url], workspace_dir) + run_git(['clone', url], workspace_dir, env=env) with open(os.path.join(workspace_dir, repo, filename), 'w') as f: f.write('A test file') + print('wrote to file', os.path.join(workspace_dir, repo, filename)) + run_git(['add', filename], repodir) run_git(['commit', '-m', 'Add a test file'], repodir) - run_git(['push', 'origin', 'master'], repodir) + run_git(['push', 'origin', 'master'], repodir, env=env) shutil.rmtree(workspace_dir) @@ -136,12 +151,14 @@ project = 'test-proj' repo = 'test-repo' filename = 'test-file' +# ssh create_test_project('git@' + trove_id, project) create_test_repo('git@' + trove_id, project, repo) can_clone('git@%s:%s/%s/%s' % (trove_id, trove_id, project, repo)) can_push('git@%s:%s/%s/%s' % (trove_id, trove_id, project, repo), repo) +# http can_clone('http://%s/git/delta/zip' % trove_id) # Test that anonymous push gets 403 @@ -151,10 +168,17 @@ try: except: print("That's great, we're expecting this to fail!") -# Ok, now for https +# https +delete_repo(trove_id, project, repo) +create_test_repo('git@' + trove_id, project, repo) + username = 'richardipsum' password = 'quack' can_clone('https://%s:%s@%s/git/%s/%s/%s' % (username, password, trove_id, trove_id, project, repo), env={'GIT_SSL_NO_VERIFY': '1'}) + +can_push('https://%s:%s@%s/git/%s/%s/%s' % + (username, password, trove_id, trove_id, project, repo), repo, + env={'GIT_SSL_NO_VERIFY': '1'}) -- cgit v1.2.1