mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
add TS test for disabled hg push
This commit is contained in:
@@ -258,12 +258,17 @@ class ShedTwillTestCase( TwillTestCase ):
|
||||
commands.commit( ui.ui(), hgrepo, **options )
|
||||
try:
|
||||
commands.push( ui.ui(), hgrepo, dest=url )
|
||||
except Abort, e:
|
||||
message = e
|
||||
except Abort as a:
|
||||
message = a
|
||||
if 'authorization failed' in message:
|
||||
return False
|
||||
else:
|
||||
raise
|
||||
except Exception as e:
|
||||
if str(e).find('Pushing to Tool Shed is disabled') != -1:
|
||||
return False
|
||||
else:
|
||||
raise
|
||||
return True
|
||||
|
||||
def create_category( self, **kwd ):
|
||||
|
||||
@@ -15,6 +15,7 @@ category_description = 'Test 0310 for verifying the tool shed http interface to
|
||||
'''
|
||||
1. Create a repository.
|
||||
2. Clone the repository to a local path.
|
||||
3. Check Mercurial push is disabled.
|
||||
'''
|
||||
|
||||
|
||||
@@ -96,3 +97,24 @@ class TestHgWebFeatures( ShedTwillTestCase ):
|
||||
self.clone_repository( repository, clone_path )
|
||||
files_in_repository = os.listdir( clone_path )
|
||||
assert 'filtering.py' in files_in_repository, 'File not found in repository: filtering.py'
|
||||
|
||||
def test_0015_commit_and_push( self ):
|
||||
'''
|
||||
Edit a file and attempt a push as a user that does have write access.
|
||||
We expect this to fail as pushing is disabled by default via disable_push config option.
|
||||
|
||||
We are at step 3 - Check Mercurial push is disabled.
|
||||
'''
|
||||
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
|
||||
clone_path = self.generate_temp_path( 'test_0310', additional_paths=[ 'filtering_0310', 'user1' ] )
|
||||
self.clone_repository( repository, clone_path )
|
||||
hgrepo = self.get_hg_repo( clone_path )
|
||||
files_in_repository = os.listdir( clone_path )
|
||||
assert 'filtering.py' in files_in_repository, 'File not found in repository: filtering.py'
|
||||
filepath = os.path.join( clone_path, 'filtering.py' )
|
||||
file_contents = [ '# This is another dummy comment to generate a new changeset.' ]
|
||||
file_contents.extend( file( filepath, 'r' ).readlines() )
|
||||
file( filepath, 'w' ).write( '\n'.join( file_contents ) )
|
||||
commit_options = dict( user=common.test_user_1_name, message='Added another line to filtering.py.' )
|
||||
success = self.commit_and_push( repository, hgrepo, commit_options, username=common.test_user_1_name, password='testuser' )
|
||||
assert success is False, 'Test user 1 (repo owner) was able to commit and push to the remote repository.'
|
||||
|
||||
Reference in New Issue
Block a user