def test_005_default_permissions( self ):
     """Testing initial settings for DefaultUserPermissions and DefaultHistoryPermissions"""
     # Logged in as admin_user
     # Make sure DefaultUserPermissions are correct
     dups = get_default_user_permissions_by_user( admin_user )
     if len( dups ) > 1:
         raise AssertionError( '%d DefaultUserPermissions associated with user %s ( should be 1 )'
                               % ( len( admin_user.default_permissions ), admin_user.email ) )
     dup = dups[0]
     if not dup.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError( 'The DefaultUserPermission.action for user "%s" is "%s", but it should be "%s"'
                               % ( admin_user.email, dup.action, galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
     # Make sure DefaultHistoryPermissions are correct
     latest_history = get_latest_history_for_user( admin_user )
     dhps = get_default_history_permissions_by_history( latest_history )
     if len( dhps ) > 1:
         raise AssertionError( '%d DefaultHistoryPermissions were created for history id %d when it was created ( should have been 1 )'
                               % ( len( latest_history.default_permissions ), latest_history.id ) )
     dhp = dhps[0]
     if not dhp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError( 'The DefaultHistoryPermission.action for history id %d is "%s", but it should be "%s"'
                               % ( latest_history.id, dhp.action, galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
     self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
                                            strings_displayed=[ admin_user.email ] )
     # Try deleting the admin_user's private role
     self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
                                            out_role_ids=str( admin_user_private_role.id ),
                                            strings_displayed=[ "You cannot eliminate a user's private role association." ] )
 def test_015_login_after_password_reset( self ):
     """Testing logging in after an admin reset a password - tests DefaultHistoryPermissions for accounts created by an admin"""
     # logged in as admin_user
     self.logout()
     self.login( email=regular_user3.email, password='******' )
     # Make sure a History and HistoryDefaultPermissions exist for the user
     latest_history = get_latest_history_for_user( regular_user3 )
     if not latest_history.user_id == regular_user3.id:
         raise AssertionError( 'A history was not created for user %s when he logged in' % regular_user3.email )
     if not latest_history.default_permissions:
         raise AssertionError( 'No DefaultHistoryPermissions were created for history id %d when it was created' % latest_history.id )
     dhps = get_default_history_permissions_by_history( latest_history )
     if len( dhps ) > 1:
         raise AssertionError( 'More than 1 DefaultHistoryPermissions were created for history id %d when it was created' % latest_history.id )
     dhp = dhps[0]
     if not dhp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError( 'The DefaultHistoryPermission.action for history id %d is "%s", but it should be "manage permissions"'
                               % ( latest_history.id, dhp.action ) )
     # Upload a file to create a HistoryDatasetAssociation
     self.upload_file( '1.bed' )
     latest_dataset = get_latest_dataset()
     for dp in latest_dataset.actions:
         # Should only have 1 DatasetPermissions
         if dp.action != galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
             raise AssertionError( 'The DatasetPermissions for dataset id %d is %s ( should have been %s )'
                                   % ( latest_dataset.id,
                                       latest_dataset.actions.action,
                                       galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
     self.logout()
     # Reset the password to the default for later tests
     self.login( email='*****@*****.**' )
     self.reset_password_as_admin( user_id=self.security.encode_id( regular_user3.id ), password='******' )
Example #3
0
 def test_005_default_permissions(self):
     """Testing initial settings for DefaultUserPermissions and DefaultHistoryPermissions"""
     # Logged in as admin_user
     # Make sure DefaultUserPermissions are correct
     dups = get_default_user_permissions_by_user(admin_user)
     if len(dups) > 1:
         raise AssertionError( '%d DefaultUserPermissions associated with user %s ( should be 1 )' \
                               % ( len( admin_user.default_permissions ), admin_user.email ) )
     dup = dups[0]
     if not dup.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError( 'The DefaultUserPermission.action for user "%s" is "%s", but it should be "%s"' \
                               % ( admin_user.email, dup.action, galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
     # Make sure DefaultHistoryPermissions are correct
     latest_history = get_latest_history_for_user(admin_user)
     dhps = get_default_history_permissions_by_history(latest_history)
     if len(dhps) > 1:
         raise AssertionError( '%d DefaultHistoryPermissions were created for history id %d when it was created ( should have been 1 )' \
                               % ( len( latest_history.default_permissions ), latest_history.id ) )
     dhp = dhps[0]
     if not dhp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError( 'The DefaultHistoryPermission.action for history id %d is "%s", but it should be "%s"' \
                               % ( latest_history.id, dhp.action, galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
     self.manage_roles_and_groups_for_user(
         self.security.encode_id(admin_user.id),
         strings_displayed=[admin_user.email])
     # Try deleting the admin_user's private role
     self.manage_roles_and_groups_for_user(
         self.security.encode_id(admin_user.id),
         out_role_ids=str(admin_user_private_role.id),
         strings_displayed=[
             "You cannot eliminate a user's private role association."
         ])
Example #4
0
 def test_015_login_after_password_reset(self):
     """Testing logging in after an admin reset a password - tests DefaultHistoryPermissions for accounts created by an admin"""
     # logged in as admin_user
     self.logout()
     self.login(email=regular_user3.email, password='******')
     # Make sure a History and HistoryDefaultPermissions exist for the user
     latest_history = get_latest_history_for_user(regular_user3)
     if not latest_history.user_id == regular_user3.id:
         raise AssertionError(
             'A history was not created for user %s when he logged in' %
             regular_user3.email)
     if not latest_history.default_permissions:
         raise AssertionError(
             'No DefaultHistoryPermissions were created for history id %d when it was created'
             % latest_history.id)
     dhps = get_default_history_permissions_by_history(latest_history)
     if len(dhps) > 1:
         raise AssertionError(
             'More than 1 DefaultHistoryPermissions were created for history id %d when it was created'
             % latest_history.id)
     dhp = dhps[0]
     if not dhp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
         raise AssertionError(
             'The DefaultHistoryPermission.action for history id %d is "%s", but it should be "manage permissions"'
             % (latest_history.id, dhp.action))
     # Upload a file to create a HistoryDatasetAssociation
     self.upload_file('1.bed')
     latest_dataset = get_latest_dataset()
     for dp in latest_dataset.actions:
         # Should only have 1 DatasetPermissions
         if dp.action != galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
             raise AssertionError(
                 'The DatasetPermissions for dataset id %d is %s ( should have been %s )'
                 % (latest_dataset.id, latest_dataset.actions.action,
                    galaxy.model.Dataset.permitted_actions.
                    DATASET_MANAGE_PERMISSIONS.action))
     self.logout()
     # Reset the password to the default for later tests
     self.login(email='*****@*****.**')
     self.reset_password_as_admin(user_id=self.security.encode_id(
         regular_user3.id),
                                  password='******')