1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/8fb3637b9655/
Changeset: 8fb3637b9655
User: davebgx
Date: 2014-03-20 20:28:26
Summary: Functional test script for granting admin privileges on a repository.
Affected #: 3 files
diff -r 593833a7ff5395bb585513ba6881012174909180 -r 8fb3637b9655a55cc54e1e5fd872bf0f9b9a48c6 test/tool_shed/base/test_db_util.py
--- a/test/tool_shed/base/test_db_util.py
+++ b/test/tool_shed/base/test_db_util.py
@@ -75,6 +75,19 @@
return role
raise AssertionError( "Private role not found for user '%s'" % user.email )
+def get_role( user, role_name ):
+ for role in user.all_roles():
+ if role.name == role_name:
+ return role
+ return None
+
+def get_repository_role_association( repository_id, role_id ):
+ rra = sa_session.query( model.RepositoryRoleAssociation ) \
+ .filter( and_( model.RepositoryRoleAssociation.table.c.role_id == role_id,
+ model.RepositoryRoleAssociation.table.c.repository_id == repository_id ) ) \
+ .first()
+ return rra
+
def get_repository_reviews( repository_id, reviewer_user_id=None, changeset_revision=None ):
if reviewer_user_id and changeset_revision:
reviews = sa_session.query( model.RepositoryReview ) \
diff -r 593833a7ff5395bb585513ba6881012174909180 -r 8fb3637b9655a55cc54e1e5fd872bf0f9b9a48c6 test/tool_shed/base/twilltestcase.py
--- a/test/tool_shed/base/twilltestcase.py
+++ b/test/tool_shed/base/twilltestcase.py
@@ -67,6 +67,14 @@
url = '/repository_review/create_component?operation=create'
self.visit_url( url )
self.submit_form( 1, 'create_component_button', **kwd )
+
+ def assign_admin_role( self, repository, user ):
+ # As elsewhere, twill limits the possibility of submitting the form, this time due to not executing the javascript
+ # attached to the role selection form. Visit the action url directly with the necessary parameters.
+ url = '/repository/manage_repository_admins?id=%s&in_users=%d&manage_role_associations_button=Save' % \
+ ( self.security.encode_id( repository.id ), user.id )
+ self.visit_url( url )
+ self.check_for_strings( strings_displayed=[ 'Role', 'has been associated' ] )
def browse_category( self, category, strings_displayed=[], strings_not_displayed=[] ):
url = '/repository/browse_valid_categories?sort=name&operation=valid_repositories_by_category&id=%s' % \
@@ -518,7 +526,7 @@
tc.submit( "manage_categories_button" )
self.check_for_strings( strings_displayed, strings_not_displayed )
- def edit_repository_information( self, repository, **kwd ):
+ def edit_repository_information( self, repository, revert=True, **kwd ):
url = '/repository/manage_repository?id=%s' % self.security.encode_id( repository.id )
self.visit_url( url )
original_information = dict( repo_name=repository.name, description=repository.description, long_description=repository.long_description )
@@ -530,12 +538,13 @@
strings_displayed.append( self.escape_html( kwd[ input_elem_name ] ) )
tc.submit( "edit_repository_button" )
self.check_for_strings( strings_displayed )
- strings_displayed = []
- for input_elem_name in [ 'repo_name', 'description', 'long_description' ]:
- tc.fv( "edit_repository", input_elem_name, original_information[ input_elem_name ] )
- strings_displayed.append( self.escape_html( original_information[ input_elem_name ] ) )
- tc.submit( "edit_repository_button" )
- self.check_for_strings( strings_displayed )
+ if revert:
+ strings_displayed = []
+ for input_elem_name in [ 'repo_name', 'description', 'long_description' ]:
+ tc.fv( "edit_repository", input_elem_name, original_information[ input_elem_name ] )
+ strings_displayed.append( self.escape_html( original_information[ input_elem_name ] ) )
+ tc.submit( "edit_repository_button" )
+ self.check_for_strings( strings_displayed )
def enable_email_alerts( self, repository, strings_displayed=[], strings_not_displayed=[] ):
repository_id = self.security.encode_id( repository.id )
diff -r 593833a7ff5395bb585513ba6881012174909180 -r 8fb3637b9655a55cc54e1e5fd872bf0f9b9a48c6 test/tool_shed/functional/test_0530_repository_admin_feature.py
--- /dev/null
+++ b/test/tool_shed/functional/test_0530_repository_admin_feature.py
@@ -0,0 +1,165 @@
+from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os
+import logging
+
+log = logging.getLogger( __name__ )
+
+repository_name = 'filtering_0530'
+repository_description = 'Filtering repository for test 0530'
+repository_long_description = 'This is the filtering repository for test 0530.'
+category_name = 'Test 0530 Repository Admin Role'
+category_description = 'Verify the functionality of the code that handles the repository admin role.'
+
+'''
+1. Create new repository as user user1.
+
+2. Check to make sure a new role was created named <repo_name>_user1_admin.
+
+3. Check to make sure a new repository_role_association record was created with appropriate repository id and role id.
+
+4. Change the name of the repository created in step 1 - this can be done as long as the repository has not been installed or cloned.
+
+5. Make sure the name of the role initially inspected in Step 2 has been changed to reflect the new repository name from Step 4.
+
+6. Log into the Tool Shed as a user that is not the repository owner (e.g., user2) and make sure the repository name
+ and description cannot be changed.
+
+7. As user user1, add user user2 as a repository admin user.
+
+8. Log into the Tool Shed as user user2 and make sure the repository name and description can now be changed.
+'''
+
+
+class TestRepositoryAdminRole( ShedTwillTestCase ):
+ '''Verify that the code correctly handles the repository admin role.'''
+
+ def test_0000_initiate_users( self ):
+ """Create necessary user accounts."""
+ self.logout()
+ self.login( email=common.test_user_1_email, username=common.test_user_1_name )
+ test_user_1 = self.test_db_util.get_user( common.test_user_1_email )
+ assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % test_user_1_email
+ test_user_1_private_role = self.test_db_util.get_private_role( test_user_1 )
+ self.logout()
+ self.login( email=common.test_user_2_email, username=common.test_user_2_name )
+ test_user_2 = self.test_db_util.get_user( common.test_user_2_email )
+ assert test_user_2 is not None, 'Problem retrieving user with email %s from the database' % test_user_2_email
+ test_user_2_private_role = self.test_db_util.get_private_role( test_user_2 )
+ self.logout()
+ self.login( email=common.admin_email, username=common.admin_username )
+ admin_user = self.test_db_util.get_user( common.admin_email )
+ assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email
+ admin_user_private_role = self.test_db_util.get_private_role( admin_user )
+
+ def test_0005_create_filtering_repository( self ):
+ """Create and populate the filtering_0530 repository."""
+ '''
+ This is step 1 - Create new repository as user user1.
+ '''
+ category = self.create_category( name=category_name, description=category_description )
+ self.logout()
+ self.login( email=common.test_user_1_email, username=common.test_user_1_name )
+ repository = self.get_or_create_repository( name=repository_name,
+ description=repository_description,
+ long_description=repository_long_description,
+ owner=common.test_user_1_name,
+ category_id=self.security.encode_id( category.id ),
+ strings_displayed=[] )
+ self.upload_file( repository,
+ filename='filtering/filtering_1.1.0.tar',
+ filepath=None,
+ valid_tools_only=True,
+ uncompress_file=True,
+ remove_repo_files_not_in_tar=False,
+ commit_message='Uploaded filtering 1.1.0 tarball.',
+ strings_displayed=[],
+ strings_not_displayed=[] )
+
+ def test_0010_verify_repository_admin_role_exists( self ):
+ '''Verify that the role filtering_0530_user1_admin exists.'''
+ '''
+ This is step 2 - Check to make sure a new role was created named filtering_0530_user1_admin.
+ '''
+ test_user_1 = self.test_db_util.get_user( common.test_user_1_email )
+ repository_admin_role = self.test_db_util.get_role( test_user_1, 'filtering_0530_user1_admin' )
+ assert repository_admin_role is not None, 'Admin role for filtering_0530 was not created.'
+
+ def test_0015_verify_repository_role_association( self ):
+ '''Verify that the filtering_0530_user1_admin role is associated with the filtering_0530 repository.'''
+ '''
+ This is step 3 - Check to make sure a new repository_role_association record was created with appropriate repository id and role id.
+ '''
+ repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
+ test_user_1 = self.test_db_util.get_user( common.test_user_1_email )
+ repository_admin_role = self.test_db_util.get_role( test_user_1, 'filtering_0530_user1_admin' )
+ repository_role_association = self.test_db_util.get_repository_role_association( repository.id, repository_admin_role.id )
+ assert repository_role_association is not None, 'Repository filtering_0530 is not associated with the filtering_0530_user1_admin role.'
+
+ def test_0020_rename_repository( self ):
+ '''Rename the repository to renamed_filtering_0530.'''
+ '''
+ This is step 4 - Change the name of the repository created in step 1 - this can be done as long as the repository has not
+ been installed or cloned.
+ '''
+ repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
+ self.edit_repository_information( repository, revert=False, repo_name='renamed_filtering_0530' )
+ self.test_db_util.refresh( repository )
+ assert repository.name == 'renamed_filtering_0530', 'Repository was not renamed to renamed_filtering_0530.'
+
+ def test_0025_check_admin_role_name( self ):
+ return
+ '''Check that a role renamed_filtering_0530_user1_admin now exists, and filtering_0530_user1_admin does not.'''
+ '''
+ This is step 5 - Make sure the name of the role initially inspected in Step 2 has been changed to reflect the
+ new repository name from Step 4.
+ '''
+ test_user_1 = self.test_db_util.get_user( common.test_user_1_email )
+ old_repository_admin_role = self.test_db_util.get_role( test_user_1, 'filtering_0530_%s_admin' % test_user_1.username )
+ assert old_repository_admin_role is None, 'Admin role filtering_0530_user1_admin incorrectly exists.'
+ new_repository_admin_role = self.test_db_util.get_role( test_user_1, 'renamed_filtering_0530_%s_admin' % test_user_1.username )
+ assert new_repository_admin_role is not None, 'Admin role renamed_filtering_0530_user1_admin does not exist.'
+
+ def test_0030_verify_access_denied( self ):
+ '''Make sure a non-admin user can't modify the repository.'''
+ '''
+ This is step 6 - Log into the Tool Shed as a user that is not the repository owner (e.g., user2) and make sure the repository
+ name and description cannot be changed.
+ '''
+ self.logout()
+ self.login( email=common.test_user_2_email, username=common.test_user_2_name )
+ repository = self.test_db_util.get_repository_by_name_and_owner( 'renamed_filtering_0530', common.test_user_1_name )
+ strings_not_displayed = [ 'Manage repository' ]
+ strings_displayed = [ 'View repository' ]
+ self.display_manage_repository_page( repository, strings_not_displayed=strings_not_displayed )
+ self.submit_form( button='edit_repository_button', description='This description has been modified.' )
+ strings_displayed = [ 'You are not the owner of this repository, so you cannot administer it.' ]
+ strings_not_displayed = [ 'The repository information has been updated.' ]
+ self.check_for_strings( strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed )
+
+ def test_0035_grant_admin_role( self ):
+ '''Grant the repository admin role to user2.'''
+ '''
+ This is step 7 - As user user1, add user user2 as a repository admin user.
+ '''
+ self.logout()
+ self.login( email=common.test_user_1_email, username=common.test_user_1_name )
+ test_user_2 = self.test_db_util.get_user( common.test_user_2_email )
+ repository = self.test_db_util.get_repository_by_name_and_owner( 'renamed_filtering_0530', common.test_user_1_name )
+ self.assign_admin_role( repository, test_user_2 )
+
+ def test_0040_rename_repository_as_repository_admin( self ):
+ '''Rename the repository as user2.'''
+ '''
+ This is step 8 - Log into the Tool Shed as user user2 and make sure the repository name and description can now be changed.
+ '''
+ self.logout()
+ self.login( email=common.test_user_2_email, username=common.test_user_2_name )
+ repository = self.test_db_util.get_repository_by_name_and_owner( 'renamed_filtering_0530', common.test_user_1_name )
+ self.edit_repository_information( repository, revert=False, repo_name='filtering_0530' )
+ self.test_db_util.refresh( repository )
+ assert repository.name == 'filtering_0530', 'User with admin role failed to rename repository.'
+ test_user_1 = self.test_db_util.get_user( common.test_user_1_email )
+ old_repository_admin_role = self.test_db_util.get_role( test_user_1, 'renamed_filtering_0530_user1_admin' )
+ assert old_repository_admin_role is None, 'Admin role renamed_filtering_0530_user1_admin incorrectly exists.'
+ new_repository_admin_role = self.test_db_util.get_role( test_user_1, 'filtering_0530_user1_admin' )
+ assert new_repository_admin_role is not None, 'Admin role filtering_0530_user1_admin does not exist.'
+
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/593833a7ff53/
Changeset: 593833a7ff53
User: jmchilton
Date: 2014-03-20 19:56:08
Summary: Small bug fix in history contents API error handling.
Affected #: 1 file
diff -r e8fac2f5d93f1ab7b87041dd5b1878705e8178af -r 593833a7ff5395bb585513ba6881012174909180 lib/galaxy/webapps/galaxy/api/history_contents.py
--- a/lib/galaxy/webapps/galaxy/api/history_contents.py
+++ b/lib/galaxy/webapps/galaxy/api/history_contents.py
@@ -286,7 +286,7 @@
if contents_type == "dataset":
return self.__update_dataset( trans, history_id, id, payload, **kwd )
else:
- return self.__handle_unknown_contents_type( contents_type )
+ return self.__handle_unknown_contents_type( trans, contents_type )
def __update_dataset( self, trans, history_id, id, payload, **kwd ):
changed = {}
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.