def test_999_reset_data_for_later_test_runs( self ):
     """Reseting data to enable later test runs to pass"""
     # Logged in as regular_user2
     self.logout()
     self.login( email=admin_user.email )
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
         refresh( user )
         if len( user.roles) != 1:
             raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
     #####################
     # Reset DefaultHistoryPermissions for regular_user1
     #####################
     self.logout()
     self.login( email=regular_user1.email )
     # Change DefaultHistoryPermissions for regular_user1 back to the default
     permissions_in = [ 'DATASET_MANAGE_PERMISSIONS' ]
     permissions_out = [ 'DATASET_ACCESS' ]
     self.user_set_default_permissions( permissions_in=permissions_in,
                                        permissions_out=permissions_out,
                                        role_id=str( regular_user1_private_role.id ) )
     self.logout()
     self.login( email=admin_user.email )
 def test_020_edit_user_info( self ):
     """Testing editing user info as a regular user"""
     # Logged in as regular_user_12
     # Test changing email and user name - first try an invalid user name
     regular_user12 = get_user( '*****@*****.**' )
     self.edit_user_info( cntrller='user',
                          new_email='*****@*****.**',
                          new_username='******',
                          strings_displayed_after_submit=[ "Public names must be at least four characters" ] )
     # Now try a valid user name
     self.edit_user_info( cntrller='user',
                          new_email='*****@*****.**',
                          new_username='******',
                          strings_displayed_after_submit=[ 'The login information has been updated with the changes' ] )
     # Since we changed the user's account. make sure the user's private role was changed accordingly
     if not get_private_role( regular_user12 ):
         raise AssertionError( "The private role for %s was not correctly set when their account (email) was changed" % regular_user12.email )
     # Test changing password
     self.edit_user_info( cntrller='user',
                          password='******',
                          new_password='******',
                          strings_displayed_after_submit=[ 'The password has been changed' ] )
     self.logout()
     refresh( regular_user12 )
     # Test logging in with new email and password
     self.login( email=regular_user12.email, password='******' )
     # Test editing the user info
     new_user_info_values = [ ( 'affiliation', 'Educational' ),
                            ( 'name_of_oganization', 'Penn State' ) ]
     self.edit_user_info( cntrller='user',
                          info_values=new_user_info_values,
                          strings_displayed_after_submit=[ "The user information has been updated with the changes" ] )
 def test_060_undelete_group( self ):
     """Testing undeleting a deleted group"""
     # Logged in as admin_user
     self.undelete_group( self.security.encode_id( group_two.id ), group_two.name )
     refresh( group_two )
     if group_two.deleted:
         raise AssertionError( '%s was not correctly marked as not deleted.' % group_two.name )
Exemple #4
0
 def test_999_reset_data_for_later_test_runs(self):
     """Reseting data to enable later test runs to pass"""
     # Logged in as regular_user2
     self.logout()
     self.login(email=admin_user.email)
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [admin_user, regular_user1, regular_user2, regular_user3]:
         refresh(user)
         if len(user.roles) != 1:
             raise AssertionError(
                 '%d UserRoleAssociations are associated with %s ( should be 1 )'
                 % (len(user.roles), user.email))
     #####################
     # Reset DefaultHistoryPermissions for regular_user1
     #####################
     self.logout()
     self.login(email=regular_user1.email)
     # Change DefaultHistoryPermissions for regular_user1 back to the default
     permissions_in = ['DATASET_MANAGE_PERMISSIONS']
     permissions_out = ['DATASET_ACCESS']
     self.user_set_default_permissions(permissions_in=permissions_in,
                                       permissions_out=permissions_out,
                                       role_id=str(
                                           regular_user1_private_role.id))
     self.logout()
     self.login(email=admin_user.email)
 def test_040_create_ldda2_with_role2_associated_with_group_and_users( self ):
     """Testing creating ldda2 with a role that is associated with a group and users"""
     # Logged in as admin_user
     # Add a dataset restricted by role2, which is currently associated as follows:
     # groups: group1
     # users: [email protected], [email protected] via group1
     #
     # We first need to make library1 public, but leave its contents permissions unchanged
     self.make_library_item_public( self.security.encode_id( library1.id ),
                                    self.security.encode_id( library1.id ),
                                    item_type='library',
                                    contents=False,
                                    library_name=library1.name )
     refresh( library1 )
     filename = '2.bed'
     ldda_message = 'ldda2'
     self.upload_library_dataset( cntrller='library_admin',
                                  library_id=self.security.encode_id( library1.id ),
                                  folder_id=self.security.encode_id( folder1.id ),
                                  filename=filename,
                                  file_type='bed',
                                  dbkey='hg17',
                                  roles=[ str( role2.id ) ],
                                  ldda_message=ldda_message,
                                  strings_displayed=[ 'Upload files' ] )
     global ldda2
     ldda2 = get_latest_ldda_by_name( filename )
     assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
     self.browse_library( cntrller='library',
                          library_id=self.security.encode_id( library1.id ),
                          strings_displayed=[ ldda2.name, ldda2.message, 'bed' ] )
 def test_999_reset_data_for_later_test_runs( self ):
     """Reseting data to enable later test runs to pass"""
     # Logged in as admin_user
     ##################
     # Delete all form definitions
     ##################
     for form in [ AddressField_form, CheckboxField_form, SelectField_form, TextArea_form, TextField_form, WorkflowField_form ]:
         self.mark_form_deleted( self.security.encode_id( form.form_definition_current.id ) )
     ##################
     # Mark all user_addresses deleted
     ##################
     for user_address in [ user_address1, user_address2 ]:
         mark_obj_deleted( user_address )
     ##################
     # Purge all libraries
     ##################
     for library in [ library1, library2, library3, library4, library5, library6 ]:
         self.delete_library_item( 'library_admin',
                                   self.security.encode_id( library.id ),
                                   self.security.encode_id( library.id ),
                                   library.name,
                                   item_type='library' )
         self.purge_library( self.security.encode_id( library.id ), library.name )
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
         refresh( user )
         if len( user.roles) != 1:
             raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
     self.logout()
Exemple #7
0
 def check_folder(library_folder):
     for folder in library_folder.folders:
         refresh(folder)
         # Make sure all of the library_folders are purged
         if not folder.purged:
             raise AssertionError(
                 'The library_folder id %s named "%s" has not been marked purged.'
                 % (str(folder.id), folder.name))
         check_folder(folder)
     # Make sure all of the LibraryDatasets and associated objects are deleted
     refresh(library_folder)
     for library_dataset in library_folder.datasets:
         refresh(library_dataset)
         ldda = library_dataset.library_dataset_dataset_association
         if ldda:
             refresh(ldda)
             if not ldda.deleted:
                 raise AssertionError(
                     'The library_dataset_dataset_association id %s named "%s" has not been marked as deleted.'
                     % (str(ldda.id), ldda.name))
             # Make sure all of the datasets have been deleted
             dataset = ldda.dataset
             refresh(dataset)
             if not dataset.deleted:
                 raise AssertionError(
                     'The dataset with id "%s" has not been marked as deleted when it should have been.'
                     % str(ldda.dataset.id))
         if not library_dataset.deleted:
             raise AssertionError(
                 'The library_dataset id %s named "%s" has not been marked as deleted.'
                 % (str(library_dataset.id), library_dataset.name))
 def test_030_create_role(self):
     """Testing creating new role with 3 members ( and a new group named the same ), then renaming the role"""
     # Logged in as admin_user
     name = 'Role One'
     description = "This is Role Ones description"
     in_user_ids = [
         str(admin_user.id),
         str(regular_user1.id),
         str(regular_user3.id)
     ]
     in_group_ids = []
     # Add 1 to the number of associated groups since we are creating a new one with the same name as the role
     num_gras = len(in_group_ids) + 1
     self.create_role(
         name=name,
         description=description,
         in_user_ids=in_user_ids,
         in_group_ids=in_group_ids,
         create_group_for_role='yes',
         private_role=admin_user.email,
         strings_displayed=[
             "Role '%s' has been created with %d associated users and %d associated groups."
             % (name, len(in_user_ids), num_gras),
             "One of the groups associated with this role is the newly created group with the same name."
         ])
     # Get the role object for later tests
     global role_one
     role_one = database_contexts.galaxy_context.query(
         galaxy.model.Role).filter(
             galaxy.model.Role.table.c.name == name).first()
     assert role_one is not None, 'Problem retrieving role named "Role One" from the database'
     # Make sure UserRoleAssociations are correct
     if len(role_one.users) != len(in_user_ids):
         raise AssertionError( '%d UserRoleAssociations were created for role id %d when it was created ( should have been %d )' \
                               % ( len( role_one.users ), role_one.id, len( in_user_ids ) ) )
     # Each of the following users should now have 2 role associations, their private role and role_one
     for user in [admin_user, regular_user1, regular_user3]:
         refresh(user)
         if len(user.roles) != 2:
             raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 2 )' \
                                   % ( len( user.roles ), user.email ) )
     # Make sure the group was created
     self.visit_url('%s/admin/groups' % self.url)
     self.check_page_for_string(name)
     global group_zero
     group_zero = get_group_by_name(name)
     # Rename the role
     rename = "Role One's been Renamed"
     new_description = "This is Role One's Re-described"
     self.rename_role(self.security.encode_id(role_one.id),
                      name=rename,
                      description=new_description)
     self.visit_url('%s/admin/roles' % self.url)
     self.check_page_for_string(rename)
     self.check_page_for_string(new_description)
     # Reset the role back to the original name and description
     self.rename_role(self.security.encode_id(role_one.id),
                      name=name,
                      description=description)
Exemple #9
0
 def test_060_undelete_group(self):
     """Testing undeleting a deleted group"""
     # Logged in as admin_user
     self.undelete_group(self.security.encode_id(group_two.id),
                         group_two.name)
     refresh(group_two)
     if group_two.deleted:
         raise AssertionError(
             '%s was not correctly marked as not deleted.' % group_two.name)
Exemple #10
0
 def test_035_create_group(self):
     """Testing creating new group with 3 members and 2 associated roles, then renaming it"""
     # Logged in as admin_user
     name = "Group One's Name"
     in_user_ids = [
         str(admin_user.id),
         str(regular_user1.id),
         str(regular_user3.id)
     ]
     in_role_ids = [str(role_one.id)]
     # The number of GroupRoleAssociations should be 2, role_one and the newly created role named 'Group One's Name'
     num_gras = len(in_role_ids) + 1
     self.create_group(
         name=name,
         in_user_ids=in_user_ids,
         in_role_ids=in_role_ids,
         create_role_for_group=True,
         strings_displayed=[
             "Group '%s' has been created with %d associated users and %d associated roles."
             % (name, len(in_user_ids), num_gras),
             "One of the roles associated with this group is the newly created role with the same name."
         ])
     # Get the group object for later tests
     global group_one
     group_one = get_group_by_name(name)
     assert group_one is not None, 'Problem retrieving group named "Group One" from the database'
     # Make sure UserGroupAssociations are correct
     if len(group_one.users) != len(in_user_ids):
         raise AssertionError(
             '%d UserGroupAssociations were created for group id %d when it was created ( should have been %d )'
             % (len(group_one.users), group_one.id, len(in_user_ids)))
     # Each user should now have 1 group association, group_one
     for user in [admin_user, regular_user1, regular_user3]:
         refresh(user)
         if len(user.groups) != 1:
             raise AssertionError(
                 '%d UserGroupAssociations are associated with user %s ( should be 1 )'
                 % (len(user.groups), user.email))
     # Make sure GroupRoleAssociations are correct
     if len(group_one.roles) != num_gras:
         raise AssertionError(
             '%d GroupRoleAssociations were created for group id %d when it was created ( should have been %d )'
             % (len(group_one.roles), group_one.id, num_gras))
     # Rename the group
     rename = "Group One's been Renamed"
     self.rename_group(
         self.security.encode_id(group_one.id),
         name=rename,
     )
     self.visit_url('%s/admin/groups' % self.url)
     self.check_page_for_string(rename)
     # Reset the group back to the original name
     self.rename_group(self.security.encode_id(group_one.id), name=name)
 def test_055_mark_group_deleted( self ):
     """Testing marking a group as deleted"""
     # Logged in as admin_user
     self.browse_groups( strings_displayed=[ group_two.name ] )
     self.mark_group_deleted( self.security.encode_id( group_two.id ), group_two.name )
     refresh( group_two )
     if not group_two.deleted:
         raise AssertionError( '%s was not correctly marked as deleted.' % group_two.name )
     # Deleting a group should not delete any associations
     if not group_two.members:
         raise AssertionError( '%s incorrectly lost all members when it was marked as deleted.' % group_two.name )
     if not group_two.roles:
         raise AssertionError( '%s incorrectly lost all role associations when it was marked as deleted.' % group_two.name )
 def test_065_mark_role_deleted( self ):
     """Testing marking a role as deleted"""
     # Logged in as admin_user
     self.browse_roles( strings_displayed=[ role_two.name ] )
     self.mark_role_deleted( self.security.encode_id( role_two.id ), role_two.name )
     refresh( role_two )
     if not role_two.deleted:
         raise AssertionError( '%s was not correctly marked as deleted.' % role_two.name )
     # Deleting a role should not delete any associations
     if not role_two.users:
         raise AssertionError( '%s incorrectly lost all user associations when it was marked as deleted.' % role_two.name )
     if not role_two.groups:
         raise AssertionError( '%s incorrectly lost all group associations when it was marked as deleted.' % role_two.name )
Exemple #13
0
 def test_060_editing_dataset_attribute_info(self):
     """Testing editing a library dataset's attribute information"""
     # logged in as admin_user
     new_ldda_name = '4.bed ( version 1 )'
     self.ldda_edit_info('library_admin',
                         self.security.encode_id(library1.id),
                         self.security.encode_id(subfolder1.id),
                         self.security.encode_id(ldda4.id),
                         ldda4.name,
                         new_ldda_name=new_ldda_name)
     refresh(ldda4)
     self.browse_library(cntrller='library_admin',
                         library_id=self.security.encode_id(library1.id),
                         strings_displayed=[new_ldda_name, ldda4.message])
Exemple #14
0
    def test_115_purge_library(self):
        """Testing purging a library"""
        # Logged in as admin_user
        self.delete_library_item('library_admin',
                                 self.security.encode_id(library1.id),
                                 self.security.encode_id(library1.id),
                                 library1.name,
                                 item_type='library')
        self.purge_library(self.security.encode_id(library1.id), library1.name)
        # Make sure the library was purged
        refresh(library1)
        if not (library1.deleted and library1.purged):
            raise AssertionError(
                'The library id %s named "%s" has not been marked as deleted and purged.'
                % (str(library1.id), library1.name))

        def check_folder(library_folder):
            for folder in library_folder.folders:
                refresh(folder)
                # Make sure all of the library_folders are purged
                if not folder.purged:
                    raise AssertionError(
                        'The library_folder id %s named "%s" has not been marked purged.'
                        % (str(folder.id), folder.name))
                check_folder(folder)
            # Make sure all of the LibraryDatasets and associated objects are deleted
            refresh(library_folder)
            for library_dataset in library_folder.datasets:
                refresh(library_dataset)
                ldda = library_dataset.library_dataset_dataset_association
                if ldda:
                    refresh(ldda)
                    if not ldda.deleted:
                        raise AssertionError(
                            'The library_dataset_dataset_association id %s named "%s" has not been marked as deleted.'
                            % (str(ldda.id), ldda.name))
                    # Make sure all of the datasets have been deleted
                    dataset = ldda.dataset
                    refresh(dataset)
                    if not dataset.deleted:
                        raise AssertionError(
                            'The dataset with id "%s" has not been marked as deleted when it should have been.'
                            % str(ldda.dataset.id))
                if not library_dataset.deleted:
                    raise AssertionError(
                        'The library_dataset id %s named "%s" has not been marked as deleted.'
                        % (str(library_dataset.id), library_dataset.name))

        check_folder(library1.root_folder)
 def test_030_create_role( self ):
     """Testing creating new role with 3 members ( and a new group named the same ), then renaming the role"""
     # Logged in as admin_user
     name = 'Role One'
     description = "This is Role Ones description"
     in_user_ids = [ str( admin_user.id ), str( regular_user1.id ), str( regular_user3.id ) ]
     in_group_ids = []
     # Add 1 to the number of associated groups since we are creating a new one with the same name as the role
     num_gras = len( in_group_ids ) + 1
     self.create_role( name=name,
                       description=description,
                       in_user_ids=in_user_ids,
                       in_group_ids=in_group_ids,
                       create_group_for_role='yes',
                       private_role=admin_user.email,
                       strings_displayed=[ "Role '%s' has been created with %d associated users and %d associated groups." % ( name, len( in_user_ids ), num_gras ),
                                           "One of the groups associated with this role is the newly created group with the same name." ] )
     # Get the role object for later tests
     global role_one
     role_one = database_contexts.galaxy_context.query( galaxy.model.Role ).filter( galaxy.model.Role.table.c.name == name ).first()
     assert role_one is not None, 'Problem retrieving role named "Role One" from the database'
     # Make sure UserRoleAssociations are correct
     if len( role_one.users ) != len( in_user_ids ):
         raise AssertionError( '%d UserRoleAssociations were created for role id %d when it was created ( should have been %d )'
                               % ( len( role_one.users ), role_one.id, len( in_user_ids ) ) )
     # Each of the following users should now have 2 role associations, their private role and role_one
     for user in [ admin_user, regular_user1, regular_user3 ]:
         refresh( user )
         if len( user.roles ) != 2:
             raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 2 )'
                                   % ( len( user.roles ), user.email ) )
     # Make sure the group was created
     self.visit_url( '%s/admin/groups' % self.url )
     self.check_page_for_string( name )
     global group_zero
     group_zero = get_group_by_name( name )
     # Rename the role
     rename = "Role One's been Renamed"
     new_description = "This is Role One's Re-described"
     self.rename_role( self.security.encode_id( role_one.id ), name=rename, description=new_description )
     self.visit_url( '%s/admin/roles' % self.url )
     self.check_page_for_string( rename )
     self.check_page_for_string( new_description )
     # Reset the role back to the original name and description
     self.rename_role( self.security.encode_id( role_one.id ), name=name, description=description )
Exemple #16
0
 def test_005_create_libraries(self):
     """Testing creating libraries used in this script, then renaming one of them"""
     # Logged in as admin_user
     for index in range(0, 3):
         name = 'library%s' % str(index + 1)
         description = '%s description' % name
         synopsis = '%s synopsis' % name
         self.create_library(name=name,
                             description=description,
                             synopsis=synopsis)
         self.browse_libraries_admin(strings_displayed=[name, description])
     # Get the libraries for later use
     global library1
     library1 = get_library('library1', 'library1 description',
                            'library1 synopsis')
     assert library1 is not None, 'Problem retrieving library (library1) from the database'
     global library2
     library2 = get_library('library2', 'library2 description',
                            'library2 synopsis')
     assert library2 is not None, 'Problem retrieving library (library2) from the database'
     global library3
     library3 = get_library('library3', 'library3 description',
                            'library3 synopsis')
     assert library3 is not None, 'Problem retrieving library (library3) from the database'
     # Rename the library
     new_name = "library1 new name"
     new_description = "library1 new description"
     new_synopsis = "library1 new synopsis"
     self.library_info('library_admin',
                       self.security.encode_id(library1.id),
                       library1.name,
                       new_name=new_name,
                       new_description=new_description,
                       new_synopsis=new_synopsis)
     self.browse_libraries_admin(
         strings_displayed=[new_name, new_description])
     # Reset the library back to the original name and description
     self.library_info('library_admin',
                       self.security.encode_id(library1.id),
                       library1.name,
                       new_name='library1',
                       new_description='library1 description',
                       new_synopsis='library1 synopsis')
     refresh(library1)
Exemple #17
0
 def test_055_mark_group_deleted(self):
     """Testing marking a group as deleted"""
     # Logged in as admin_user
     self.browse_groups(strings_displayed=[group_two.name])
     self.mark_group_deleted(self.security.encode_id(group_two.id),
                             group_two.name)
     refresh(group_two)
     if not group_two.deleted:
         raise AssertionError('%s was not correctly marked as deleted.' %
                              group_two.name)
     # Deleting a group should not delete any associations
     if not group_two.members:
         raise AssertionError(
             '%s incorrectly lost all members when it was marked as deleted.'
             % group_two.name)
     if not group_two.roles:
         raise AssertionError(
             '%s incorrectly lost all role associations when it was marked as deleted.'
             % group_two.name)
 def test_020_edit_user_info(self):
     """Testing editing user info as a regular user"""
     # Logged in as regular_user_12
     # Test changing email and user name - first try an invalid user name
     regular_user12 = get_user('*****@*****.**')
     self.edit_user_info(cntrller='user',
                         new_email='*****@*****.**',
                         new_username='******',
                         strings_displayed_after_submit=[
                             "Public names must be at least four characters"
                         ])
     # Now try a valid user name
     self.edit_user_info(
         cntrller='user',
         new_email='*****@*****.**',
         new_username='******',
         strings_displayed_after_submit=[
             'The login information has been updated with the changes'
         ])
     # Since we changed the user's account. make sure the user's private role was changed accordingly
     if not get_private_role(regular_user12):
         raise AssertionError(
             "The private role for %s was not correctly set when their account (email) was changed"
             % regular_user12.email)
     # Test changing password
     self.edit_user_info(
         cntrller='user',
         password='******',
         new_password='******',
         strings_displayed_after_submit=['The password has been changed'])
     self.logout()
     refresh(regular_user12)
     # Test logging in with new email and password
     self.login(email=regular_user12.email, password='******')
     # Test editing the user info
     new_user_info_values = [('affiliation', 'Educational'),
                             ('name_of_oganization', 'Penn State')]
     self.edit_user_info(
         cntrller='user',
         info_values=new_user_info_values,
         strings_displayed_after_submit=[
             "The user information has been updated with the changes"
         ])
Exemple #19
0
 def test_065_mark_role_deleted(self):
     """Testing marking a role as deleted"""
     # Logged in as admin_user
     self.browse_roles(strings_displayed=[role_two.name])
     self.mark_role_deleted(self.security.encode_id(role_two.id),
                            role_two.name)
     refresh(role_two)
     if not role_two.deleted:
         raise AssertionError('%s was not correctly marked as deleted.' %
                              role_two.name)
     # Deleting a role should not delete any associations
     if not role_two.users:
         raise AssertionError(
             '%s incorrectly lost all user associations when it was marked as deleted.'
             % role_two.name)
     if not role_two.groups:
         raise AssertionError(
             '%s incorrectly lost all group associations when it was marked as deleted.'
             % role_two.name)
Exemple #20
0
 def test_050_change_user_role_associations(self):
     """Testing changing roles associated with a user"""
     # Logged in as admin_user
     # Create a new role with no associations
     name = 'Role Three'
     description = 'This is Role Three'
     user_ids = []
     group_ids = []
     private_role = admin_user.email
     self.create_role(name=name,
                      description=description,
                      in_user_ids=user_ids,
                      in_group_ids=group_ids,
                      private_role=private_role)
     # Get the role object for later tests
     global role_three
     role_three = get_role_by_name(name)
     assert role_three is not None, 'Problem retrieving role named "Role Three" from the database'
     # Associate the role with a user
     refresh(admin_user)
     role_ids = []
     for ura in admin_user.non_private_roles:
         role_ids.append(str(ura.role_id))
     role_ids.append(str(role_three.id))
     group_ids = []
     for uga in admin_user.groups:
         group_ids.append(str(uga.group_id))
     strings_displayed = [
         "User '%s' has been updated with %d associated roles and %d associated groups"
         % (admin_user.email, len(role_ids), len(group_ids))
     ]
     self.manage_roles_and_groups_for_user(
         self.security.encode_id(admin_user.id),
         in_role_ids=role_ids,
         in_group_ids=group_ids,
         strings_displayed=strings_displayed)
     refresh(admin_user)
     # admin_user should now be associated with 4 roles: private, role_one, role_two, role_three
     if len(admin_user.roles) != 4:
         raise AssertionError(
             '%d UserRoleAssociations are associated with %s ( should be 4 )'
             % (len(admin_user.roles), admin_user.email))
 def test_999_reset_data_for_later_test_runs(self):
     """Reseting data to enable later test runs to pass"""
     # Logged in as regular_user_12
     self.logout()
     self.login(email=admin_user.email)
     ##################
     # Mark all forms deleted that have not yet been marked deleted ( form_two has )
     ##################
     for form in [form_one]:
         self.mark_form_deleted(self.security.encode_id(form.current.id))
     ###############
     # Purge private roles
     ###############
     for role in [regular_user11_private_role, regular_user12_private_role]:
         self.mark_role_deleted(self.security.encode_id(role.id), role.name)
         self.purge_role(self.security.encode_id(role.id), role.name)
         # Manually delete the role from the database
         refresh(role)
         delete_obj(role)
     ###############
     # Purge appropriate users
     ###############
     for user in [regular_user11, regular_user12]:
         self.mark_user_deleted(user_id=self.security.encode_id(user.id),
                                email=user.email)
         refresh(user)
         self.purge_user(self.security.encode_id(user.id), user.email)
         refresh(user)
         delete_user_roles(user)
         delete_obj(user)
 def test_999_reset_data_for_later_test_runs( self ):
     """Reseting data to enable later test runs to pass"""
     # Logged in as admin_user
     ##################
     # Eliminate all non-private roles
     ##################
     for role in [ role_one, role_two, role_three ]:
         self.mark_role_deleted( self.security.encode_id( role.id ), role.name )
         self.purge_role( self.security.encode_id( role.id ), role.name )
         # Manually delete the role from the database
         refresh( role )
         database_contexts.galaxy_context.delete( role )
         database_contexts.galaxy_context.flush()
     ##################
     # Eliminate all groups
     ##################
     for group in [ group_zero, group_one, group_two ]:
         self.mark_group_deleted( self.security.encode_id( group.id ), group.name )
         self.purge_group( self.security.encode_id( group.id ), group.name )
         # Manually delete the group from the database
         refresh( group )
         database_contexts.galaxy_context.delete( group )
         database_contexts.galaxy_context.flush()
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
         refresh( user )
         if len( user.roles) != 1:
             raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
 def test_075_purge_user( self ):
     """Testing purging a user account"""
     # Logged in as admin_user
     self.mark_user_deleted( user_id=self.security.encode_id( regular_user3.id ), email=regular_user3.email )
     refresh( regular_user3 )
     self.purge_user( self.security.encode_id( regular_user3.id ), regular_user3.email )
     refresh( regular_user3 )
     if not regular_user3.purged:
         raise AssertionError( 'User %s was not marked as purged.' % regular_user3.email )
     # Make sure DefaultUserPermissions deleted EXCEPT FOR THE PRIVATE ROLE
     if len( regular_user3.default_permissions ) != 1:
         raise AssertionError( 'DefaultUserPermissions for user %s were not deleted.' % regular_user3.email )
     for dup in regular_user3.default_permissions:
         role = database_contexts.galaxy_context.query( galaxy.model.Role ).get( dup.role_id )
         if role.type != 'private':
             raise AssertionError( 'DefaultUserPermissions for user %s are not related with the private role.' % regular_user3.email )
     # Make sure History deleted
     for history in regular_user3.histories:
         refresh( history )
         if not history.deleted:
             raise AssertionError( 'User %s has active history id %d after their account was marked as purged.' % ( regular_user3.email, history.id ) )
         # NOTE: Not all hdas / datasets will be deleted at the time a history is deleted - the cleanup_datasets.py script
         # is responsible for this.
     # Make sure UserGroupAssociations deleted
     if regular_user3.groups:
         raise AssertionError( 'User %s has active group after their account was marked as purged.' % ( regular_user3.email ) )
     # Make sure UserRoleAssociations deleted EXCEPT FOR THE PRIVATE ROLE
     if len( regular_user3.roles ) != 1:
         raise AssertionError( 'UserRoleAssociations for user %s were not deleted.' % regular_user3.email )
     for ura in regular_user3.roles:
         role = database_contexts.galaxy_context.query( galaxy.model.Role ).get( ura.role_id )
         if role.type != 'private':
             raise AssertionError( 'UserRoleAssociations for user %s are not related with the private role.' % regular_user3.email )
Exemple #24
0
 def test_999_reset_data_for_later_test_runs(self):
     """Reseting data to enable later test runs to pass"""
     # Logged in as admin_user
     ##################
     # Eliminate all non-private roles
     ##################
     for role in [role_one, role_two, role_three]:
         self.mark_role_deleted(self.security.encode_id(role.id), role.name)
         self.purge_role(self.security.encode_id(role.id), role.name)
         # Manually delete the role from the database
         refresh(role)
         database_contexts.galaxy_context.delete(role)
         database_contexts.galaxy_context.flush()
     ##################
     # Eliminate all groups
     ##################
     for group in [group_zero, group_one, group_two]:
         self.mark_group_deleted(self.security.encode_id(group.id),
                                 group.name)
         self.purge_group(self.security.encode_id(group.id), group.name)
         # Manually delete the group from the database
         refresh(group)
         database_contexts.galaxy_context.delete(group)
         database_contexts.galaxy_context.flush()
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [admin_user, regular_user1, regular_user2, regular_user3]:
         refresh(user)
         if len(user.roles) != 1:
             raise AssertionError(
                 '%d UserRoleAssociations are associated with %s ( should be 1 )'
                 % (len(user.roles), user.email))
 def test_999_reset_data_for_later_test_runs( self ):
     """Reseting data to enable later test runs to pass"""
     # Logged in as regular_user_12
     self.logout()
     self.login( email=admin_user.email )
     ##################
     # Mark all forms deleted that have not yet been marked deleted ( form_two has )
     ##################
     for form in [ form_one ]:
         self.mark_form_deleted( self.security.encode_id( form.current.id ) )
     ###############
     # Purge private roles
     ###############
     for role in [ regular_user11_private_role, regular_user12_private_role ]:
         self.mark_role_deleted( self.security.encode_id( role.id ), role.name )
         self.purge_role( self.security.encode_id( role.id ), role.name )
         # Manually delete the role from the database
         refresh( role )
         delete_obj( role )
     ###############
     # Purge appropriate users
     ###############
     for user in [ regular_user11, regular_user12 ]:
         self.mark_user_deleted( user_id=self.security.encode_id( user.id ), email=user.email )
         refresh( user )
         self.purge_user( self.security.encode_id( user.id ), user.email )
         refresh( user )
         delete_user_roles( user )
         delete_obj( user )
 def test_035_create_group( self ):
     """Testing creating new group with 3 members and 2 associated roles, then renaming it"""
     # Logged in as admin_user
     name = "Group One's Name"
     in_user_ids = [ str( admin_user.id ), str( regular_user1.id ), str( regular_user3.id ) ]
     in_role_ids = [ str( role_one.id ) ]
     # The number of GroupRoleAssociations should be 2, role_one and the newly created role named 'Group One's Name'
     num_gras = len( in_role_ids ) + 1
     self.create_group( name=name,
                        in_user_ids=in_user_ids,
                        in_role_ids=in_role_ids,
                        create_role_for_group='yes',
                        strings_displayed=[ "Group '%s' has been created with %d associated users and %d associated roles." % ( name, len( in_user_ids ), num_gras ),
                                            "One of the roles associated with this group is the newly created role with the same name." ] )
     # Get the group object for later tests
     global group_one
     group_one = get_group_by_name( name )
     assert group_one is not None, 'Problem retrieving group named "Group One" from the database'
     # Make sure UserGroupAssociations are correct
     if len( group_one.users ) != len( in_user_ids ):
         raise AssertionError( '%d UserGroupAssociations were created for group id %d when it was created ( should have been %d )' \
                               % ( len( group_one.users ), group_one.id, len( in_user_ids ) ) )
     # Each user should now have 1 group association, group_one
     for user in [ admin_user, regular_user1, regular_user3 ]:
         refresh( user )
         if len( user.groups ) != 1:
             raise AssertionError( '%d UserGroupAssociations are associated with user %s ( should be 1 )' % ( len( user.groups ), user.email ) )
     # Make sure GroupRoleAssociations are correct
     if len( group_one.roles ) != num_gras:
         raise AssertionError( '%d GroupRoleAssociations were created for group id %d when it was created ( should have been %d )' \
                               % ( len( group_one.roles ), group_one.id, num_gras ) )
     # Rename the group
     rename = "Group One's been Renamed"
     self.rename_group( self.security.encode_id( group_one.id ), name=rename, )
     self.home()
     self.visit_url( '%s/admin/groups' % self.url )
     self.check_page_for_string( rename )
     # Reset the group back to the original name
     self.rename_group( self.security.encode_id( group_one.id ), name=name )
 def test_050_change_user_role_associations( self ):
     """Testing changing roles associated with a user"""
     # Logged in as admin_user
     # Create a new role with no associations
     name = 'Role Three'
     description = 'This is Role Three'
     user_ids = []
     group_ids = []
     private_role = admin_user.email
     self.create_role( name=name,
                       description=description,
                       in_user_ids=user_ids,
                       in_group_ids=group_ids,
                       private_role=private_role )
     # Get the role object for later tests
     global role_three
     role_three = get_role_by_name( name )
     assert role_three is not None, 'Problem retrieving role named "Role Three" from the database'
     # Associate the role with a user
     refresh( admin_user )
     role_ids = []
     for ura in admin_user.non_private_roles:
         role_ids.append( str( ura.role_id ) )
     role_ids.append( str( role_three.id ) )
     group_ids = []
     for uga in admin_user.groups:
         group_ids.append( str( uga.group_id ) )
     strings_displayed = [ "User '%s' has been updated with %d associated roles and %d associated groups" %
                         ( admin_user.email, len( role_ids ), len( group_ids ) ) ]
     self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
                                            in_role_ids=role_ids,
                                            in_group_ids=group_ids,
                                            strings_displayed=strings_displayed )
     refresh( admin_user )
     # admin_user should now be associated with 4 roles: private, role_one, role_two, role_three
     if len( admin_user.roles ) != 4:
         raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 4 )' %
                               ( len( admin_user.roles ), admin_user.email ) )
Exemple #28
0
 def test_999_reset_data_for_later_test_runs(self):
     """Reseting data to enable later test runs to pass"""
     # Logged in as admin_user
     ##################
     # Purge all libraries
     ##################
     for library in [library1, library2, library3]:
         self.delete_library_item('library_admin',
                                  self.security.encode_id(library.id),
                                  self.security.encode_id(library.id),
                                  library.name,
                                  item_type='library')
         self.purge_library(self.security.encode_id(library.id),
                            library.name)
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [admin_user, regular_user1, regular_user2, regular_user3]:
         refresh(user)
         if len(user.roles) != 1:
             raise AssertionError(
                 '%d UserRoleAssociations are associated with %s ( should be 1 )'
                 % (len(user.roles), user.email))
     self.logout()
Exemple #29
0
 def test_075_purge_user(self):
     """Testing purging a user account"""
     # Logged in as admin_user
     self.mark_user_deleted(user_id=self.security.encode_id(
         regular_user3.id),
                            email=regular_user3.email)
     refresh(regular_user3)
     self.purge_user(self.security.encode_id(regular_user3.id),
                     regular_user3.email)
     refresh(regular_user3)
     if not regular_user3.purged:
         raise AssertionError('User %s was not marked as purged.' %
                              regular_user3.email)
     # Make sure DefaultUserPermissions deleted EXCEPT FOR THE PRIVATE ROLE
     if len(regular_user3.default_permissions) != 1:
         raise AssertionError(
             'DefaultUserPermissions for user %s were not deleted.' %
             regular_user3.email)
     for dup in regular_user3.default_permissions:
         role = database_contexts.galaxy_context.query(
             galaxy.model.Role).get(dup.role_id)
         if role.type != 'private':
             raise AssertionError(
                 'DefaultUserPermissions for user %s are not related with the private role.'
                 % regular_user3.email)
     # Make sure History deleted
     for history in regular_user3.histories:
         refresh(history)
         if not history.deleted:
             raise AssertionError(
                 'User %s has active history id %d after their account was marked as purged.'
                 % (regular_user3.email, history.id))
         # NOTE: Not all hdas / datasets will be deleted at the time a history is deleted - the cleanup_datasets.py script
         # is responsible for this.
     # Make sure UserGroupAssociations deleted
     if regular_user3.groups:
         raise AssertionError(
             'User %s has active group after their account was marked as purged.'
             % (regular_user3.email))
     # Make sure UserRoleAssociations deleted EXCEPT FOR THE PRIVATE ROLE
     if len(regular_user3.roles) != 1:
         raise AssertionError(
             'UserRoleAssociations for user %s were not deleted.' %
             regular_user3.email)
     for ura in regular_user3.roles:
         role = database_contexts.galaxy_context.query(
             galaxy.model.Role).get(ura.role_id)
         if role.type != 'private':
             raise AssertionError(
                 'UserRoleAssociations for user %s are not related with the private role.'
                 % regular_user3.email)
Exemple #30
0
 def test_045_create_role_with_user_and_group_associations(self):
     """Testing creating a role with user and group associations"""
     # Logged in as admin_user
     # NOTE: To get this to work with twill, all select lists on the ~/admin/role page must contain at least
     # 1 option value or twill throws an exception, which is: ParseError: OPTION outside of SELECT
     # Due to this bug in twill, we create the role, we bypass the page and visit the URL in the
     # associate_users_and_groups_with_role() method.
     name = 'Role Two'
     description = 'This is Role Two'
     user_ids = [str(admin_user.id)]
     group_ids = [str(group_two.id)]
     private_role = admin_user.email
     # Create the role
     self.create_role(name=name,
                      description=description,
                      in_user_ids=user_ids,
                      in_group_ids=group_ids,
                      private_role=private_role)
     # Get the role object for later tests
     global role_two
     role_two = get_role_by_name(name)
     assert role_two is not None, 'Problem retrieving role named "Role Two" from the database'
     # Make sure UserRoleAssociations are correct
     if len(role_two.users) != len(user_ids):
         raise AssertionError(
             '%d UserRoleAssociations were created for role id %d when it was created with %d members'
             % (len(role_two.users), role_two.id, len(user_ids)))
     # admin_user should now have 3 role associations, private role, role_one, role_two
     refresh(admin_user)
     if len(admin_user.roles) != 3:
         raise AssertionError(
             '%d UserRoleAssociations are associated with user %s ( should be 3 )'
             % (len(admin_user.roles), admin_user.email))
     # Make sure GroupRoleAssociations are correct
     refresh(role_two)
     if len(role_two.groups) != len(group_ids):
         raise AssertionError(
             '%d GroupRoleAssociations were created for role id %d when it was created ( should have been %d )'
             % (len(role_two.groups), role_two.id, len(group_ids)))
     # group_two should now be associated with 2 roles: role_one, role_two
     refresh(group_two)
     if len(group_two.roles) != 2:
         raise AssertionError(
             '%d GroupRoleAssociations are associated with group id %d ( should be 2 )'
             % (len(group_two.roles), group_two.id))
 def test_999_reset_data_for_later_test_runs( self ):
     """Reseting data to enable later test runs to pass"""
     # Logged in as regular_user2
     self.logout()
     self.login( email=admin_user.email )
     ##################
     # Purge all libraries
     ##################
     for library in [ library1, library2 ]:
         self.delete_library_item( 'library_admin',
                                   self.security.encode_id( library.id ),
                                   self.security.encode_id( library.id ),
                                   library.name,
                                   item_type='library' )
         self.purge_library( self.security.encode_id( library.id ), library.name )
     ##################
     # Eliminate all non-private roles
     ##################
     for role in [ role1, role2 ]:
         self.mark_role_deleted( self.security.encode_id( role.id ), role.name )
         self.purge_role( self.security.encode_id( role.id ), role.name )
         # Manually delete the role from the database
         refresh( role )
         sa_session.delete( role )
         sa_session.flush()
     ##################
     # Eliminate all groups
     ##################
     for group in [ group1 ]:
         self.mark_group_deleted( self.security.encode_id( group.id ), group.name )
         self.purge_group( self.security.encode_id( group.id ), group.name )
         # Manually delete the group from the database
         refresh( group )
         sa_session.delete( group )
         sa_session.flush()
     ##################
     # Make sure all users are associated only with their private roles
     ##################
     for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
         refresh( user )
         if len( user.roles) != 1:
             raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
 def test_045_create_role_with_user_and_group_associations( self ):
     """Testing creating a role with user and group associations"""
     # Logged in as admin_user
     # NOTE: To get this to work with twill, all select lists on the ~/admin/role page must contain at least
     # 1 option value or twill throws an exception, which is: ParseError: OPTION outside of SELECT
     # Due to this bug in twill, we create the role, we bypass the page and visit the URL in the
     # associate_users_and_groups_with_role() method.
     name = 'Role Two'
     description = 'This is Role Two'
     user_ids = [ str( admin_user.id ) ]
     group_ids = [ str( group_two.id ) ]
     private_role = admin_user.email
     # Create the role
     self.create_role( name=name,
                       description=description,
                       in_user_ids=user_ids,
                       in_group_ids=group_ids,
                       private_role=private_role )
     # Get the role object for later tests
     global role_two
     role_two = get_role_by_name( name )
     assert role_two is not None, 'Problem retrieving role named "Role Two" from the database'
     # Make sure UserRoleAssociations are correct
     if len( role_two.users ) != len( user_ids ):
         raise AssertionError( '%d UserRoleAssociations were created for role id %d when it was created with %d members'
                               % ( len( role_two.users ), role_two.id, len( user_ids ) ) )
     # admin_user should now have 3 role associations, private role, role_one, role_two
     refresh( admin_user )
     if len( admin_user.roles ) != 3:
         raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 3 )' % ( len( admin_user.roles ), admin_user.email ) )
     # Make sure GroupRoleAssociations are correct
     refresh( role_two )
     if len( role_two.groups ) != len( group_ids ):
         raise AssertionError( '%d GroupRoleAssociations were created for role id %d when it was created ( should have been %d )'
                               % ( len( role_two.groups ), role_two.id, len( group_ids ) ) )
     # group_two should now be associated with 2 roles: role_one, role_two
     refresh( group_two )
     if len( group_two.roles ) != 2:
         raise AssertionError( '%d GroupRoleAssociations are associated with group id %d ( should be 2 )' % ( len( group_two.roles ), group_two.id ) )