def test_000_initiate_users( self ): """Ensuring all required user accounts exist""" self.logout() self.login( email='*****@*****.**', username='******' ) global regular_user1 regular_user1 = get_user( '*****@*****.**' ) assert regular_user1 is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global regular_user1_private_role regular_user1_private_role = get_private_role( regular_user1 ) self.logout() self.login( email='*****@*****.**', username='******' ) global regular_user2 regular_user2 = get_user( '*****@*****.**' ) assert regular_user2 is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global regular_user2_private_role regular_user2_private_role = get_private_role( regular_user2 ) self.logout() self.login( email='*****@*****.**', username='******' ) global regular_user3 regular_user3 = get_user( '*****@*****.**' ) assert regular_user3 is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global regular_user3_private_role regular_user3_private_role = get_private_role( regular_user3 ) self.logout() self.login( email='*****@*****.**', username='******' ) global admin_user admin_user = get_user( '*****@*****.**' ) assert admin_user is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global admin_user_private_role admin_user_private_role = get_private_role( admin_user )
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_015_user_reqistration_single_user_info_forms( self ): """Testing user registration with a single user info form""" # Logged in as regular_user_11 self.logout() self.login( email=admin_user.email ) # Delete the 'Researcher' user info form self.mark_form_deleted( self.security.encode_id( form_two.current.id ) ) # Create a new user with 'Student' user info form. The user_info_values will be the values # filled into the fields defined in field_dicts above ( 'Educational' -> 'Affiliation, # 'Penn State' -> 'Name of Organization', '1' -> 'Contact for feedback' ) email = '*****@*****.**' password = '******' username = '******' user_info_values = [ ( 'affiliation', 'Educational' ), ( 'name_of_oganization', 'Penn State' ), ( 'contact_for_feedback', '1' ) ] self.create_user_with_info( cntrller='admin', email=email, password=password, username=username, user_type_fd_id=self.security.encode_id( form_one.id ), user_info_values=user_info_values, strings_displayed=[ "Create account", "User type" ] ) global regular_user12 regular_user12 = get_user( email ) assert regular_user12 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user12_private_role regular_user12_private_role = get_private_role( regular_user12 ) self.logout() self.login( email=regular_user12.email, username=username ) self.edit_user_info( cntrller='user', strings_displayed=[ "Manage User Information", user_info_values[0][1], user_info_values[1][1], form_checkbox_field3_string ] )
def test_010_user_reqistration_multiple_user_info_forms( self ): """Testing user registration with multiple user info forms""" # Logged in as admin_user self.logout() # Create a new user with 'Student' user info form. The user_info_values will be the values # filled into the fields defined in field_dicts above ( 'Educational' -> 'Affiliation, # 'Penn State' -> 'Name of Organization', '1' -> 'Contact for feedback' ) email = '*****@*****.**' password = '******' username = '******' user_info_values = [ ( 'affiliation', 'Educational' ), ( 'name_of_oganization', 'Penn State' ), ( 'contact_for_feedback', '1' ) ] self.create_user_with_info( cntrller='admin', email=email, password=password, username=username, user_type_fd_id=self.security.encode_id( form_one.id ), user_info_values=user_info_values, strings_displayed=[ "Create account", "User type" ] ) global regular_user11 regular_user11 = get_user( email ) assert regular_user11 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user11_private_role regular_user11_private_role = get_private_role( regular_user11 ) self.logout() self.login( email=regular_user11.email, username=username ) global form_checkbox_field3_string form_checkbox_field3_string = '<input type="checkbox" id="contact_for_feedback" name="contact_for_feedback" value="true" checked="checked">' self.edit_user_info( cntrller='user', strings_displayed=[ "Manage User Information", user_info_values[0][1], user_info_values[1][1], form_checkbox_field3_string ] )
def test_0000_setup_upload_tests( self ): """ Configuring upload tests, setting admin_user """ self.logout() self.login( email='*****@*****.**' ) global admin_user admin_user = get_user( email='*****@*****.**' )
def test_0000_setup_upload_tests(self): """ Configuring upload tests, setting admin_user """ self.logout() self.login(email='*****@*****.**') global admin_user admin_user = get_user(email='*****@*****.**')
def test_005_create_new_user_account_as_admin( self ): """Testing creating a new user account as admin""" # Logged in as admin_user email = '*****@*****.**' password = '******' # Test setting the user name to one that is already taken. Note that the account must not exist in order # for this test to work as desired, so the email we're passing is important... previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email='*****@*****.**', password=password, username='******', redirect='' ) if not username_taken: error_msg = "The public name (%s) is already being used by another user, but no error was displayed" % 'admin-user' raise AssertionError( error_msg ) # Test setting the user name to an invalid one. Note that the account must not exist in order # for this test to work as desired, so the email we're passing is important... previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email='*****@*****.**', password=password, username='******', redirect='' ) if not invalid_username: raise AssertionError( "The public name (%s) is is invalid, but no error was displayed" % '*****@*****.**' ) previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email=email, password=password, username='******', redirect='' ) # Get the user object for later tests global regular_user3 regular_user3 = get_user( email ) assert regular_user3 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user3_private_role regular_user3_private_role = get_private_role( regular_user3 ) # Make sure DefaultUserPermissions were created if not regular_user3.default_permissions: raise AssertionError( 'No DefaultUserPermissions were created for user %s when the admin created the account' % email ) # Make sure a private role was created for the user if not regular_user3.roles: raise AssertionError( 'No UserRoleAssociations were created for user %s when the admin created the account' % email ) if not previously_created and len( regular_user3.roles ) != 1: raise AssertionError( '%d UserRoleAssociations were created for user %s when the admin created the account ( should have been 1 )' % ( len( regular_user3.roles ), regular_user3.email ) ) for ura in regular_user3.roles: role = database_contexts.galaxy_context.query( galaxy.model.Role ).get( ura.role_id ) if not previously_created and role.type != 'private': raise AssertionError( 'Role created for user %s when the admin created the account is not private, type is' % str( role.type ) ) if not previously_created: # Make sure a history was not created ( previous test runs may have left deleted histories ) histories = get_all_histories_for_user( regular_user3 ) if histories: raise AssertionError( 'Histories were incorrectly created for user %s when the admin created the account' % email ) # Make sure the user was not associated with any groups if regular_user3.groups: raise AssertionError( 'Groups were incorrectly associated with user %s when the admin created the account' % email )
def test_0005_get_mm10_5HTT_sequence( self ): self.logout() self.login( email='*****@*****.**' ) test_db_util.get_user( '*****@*****.**' ) self.new_history( name='UCSC_Main' ) track_params = dict( db="mm10", hgta_group="genes", hgta_table="knownGene", hgta_track="knownGene", hgta_regionType="range", position="chr5:34761740-34912521", hgta_outputType="sequence", sendToGalaxy="1" ) output_params = dict( fbQual="whole", ) self.run_ucsc_main( track_params, output_params ) self.wait() self.verify_dataset_correctness( 'GRCm38mm10_chr5_34761740-34912521.fa' )
def test_0000_initiate_users( self ): """Ensuring all required user accounts exist""" self.logout() self.login( email='*****@*****.**', username='******' ) global admin_user admin_user = test_db_util.get_user( '*****@*****.**' ) assert admin_user is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global admin_user_private_role admin_user_private_role = test_db_util.get_private_role( admin_user ) latest_history = test_db_util.get_latest_history_for_user( admin_user ) self.delete_history( id=self.security.encode_id( latest_history.id ) ) self.new_history() latest_history = test_db_util.get_latest_history_for_user( admin_user ) assert latest_history is not None, "Problem retrieving latest_history from database"
def test_0000_initiate_users(self): """Ensuring all required user accounts exist""" self.logout() self.login(email='*****@*****.**', username='******') global admin_user admin_user = test_db_util.get_user('*****@*****.**') assert admin_user is not None, 'Problem retrieving user with email "*****@*****.**" from the database' global admin_user_private_role admin_user_private_role = test_db_util.get_private_role(admin_user) latest_history = test_db_util.get_latest_history_for_user(admin_user) self.delete_history(id=self.security.encode_id(latest_history.id)) self.new_history() latest_history = test_db_util.get_latest_history_for_user(admin_user) assert latest_history is not None, "Problem retrieving latest_history from database"
def test_0005_get_mm10_5HTT_sequence(self): self.logout() self.login(email='*****@*****.**') admin_user = test_db_util.get_user('*****@*****.**') self.new_history(name='UCSC_Main') track_params = dict(db="mm10", hgta_group="genes", hgta_table="knownGene", hgta_track="knownGene", hgta_regionType="range", position="chr5:34761740-34912521", hgta_outputType="sequence", sendToGalaxy="1") output_params = dict(fbQual="whole", ) self.run_ucsc_main(track_params, output_params) self.wait() self.verify_dataset_correctness('GRCm38mm10_chr5_34761740-34912521.fa')
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_015_user_reqistration_single_user_info_forms(self): """Testing user registration with a single user info form""" # Logged in as regular_user_11 self.logout() self.login(email=admin_user.email) # Delete the 'Researcher' user info form self.mark_form_deleted(self.security.encode_id(form_two.current.id)) # Create a new user with 'Student' user info form. The user_info_values will be the values # filled into the fields defined in field_dicts above ( 'Educational' -> 'Affiliation, # 'Penn State' -> 'Name of Organization', '1' -> 'Contact for feedback' ) email = '*****@*****.**' password = '******' username = '******' user_info_values = [('affiliation', 'Educational'), ('name_of_oganization', 'Penn State'), ('contact_for_feedback', '1')] self.create_user_with_info( cntrller='admin', email=email, password=password, username=username, user_type_fd_id=self.security.encode_id(form_one.id), user_info_values=user_info_values, strings_displayed=["Create account", "User type"]) global regular_user12 regular_user12 = get_user(email) assert regular_user12 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user12_private_role regular_user12_private_role = get_private_role(regular_user12) self.logout() self.login(email=regular_user12.email, username=username) self.edit_user_info(cntrller='user', strings_displayed=[ "Manage User Information", user_info_values[0][1], user_info_values[1][1], form_checkbox_field3_string ])
def test_010_user_reqistration_multiple_user_info_forms(self): """Testing user registration with multiple user info forms""" # Logged in as admin_user self.logout() # Create a new user with 'Student' user info form. The user_info_values will be the values # filled into the fields defined in field_dicts above ( 'Educational' -> 'Affiliation, # 'Penn State' -> 'Name of Organization', '1' -> 'Contact for feedback' ) email = '*****@*****.**' password = '******' username = '******' user_info_values = [('affiliation', 'Educational'), ('name_of_oganization', 'Penn State'), ('contact_for_feedback', '1')] self.create_user_with_info( cntrller='admin', email=email, password=password, username=username, user_type_fd_id=self.security.encode_id(form_one.id), user_info_values=user_info_values, strings_displayed=["Create account", "User type"]) global regular_user11 regular_user11 = get_user(email) assert regular_user11 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user11_private_role regular_user11_private_role = get_private_role(regular_user11) self.logout() self.login(email=regular_user11.email, username=username) global form_checkbox_field3_string form_checkbox_field3_string = '<input type="checkbox" id="contact_for_feedback" name="contact_for_feedback" value="true" checked="checked">' self.edit_user_info(cntrller='user', strings_displayed=[ "Manage User Information", user_info_values[0][1], user_info_values[1][1], form_checkbox_field3_string ])
def test_010_private_role_creation_and_default_history_permissions( self ): """Testing private role creation and changing DefaultHistoryPermissions for new histories""" # Logged in as admin_user self.logout() # Some of the history related tests here are similar to some tests in the # test_history_functions.py script, so we could potentially eliminate 1 or 2 of them. self.login( email='*****@*****.**' ) global regular_user1 regular_user1 = get_user( '*****@*****.**' ) assert regular_user1 is not None, 'Problem retrieving user with email "*****@*****.**" from the database' # Add a dataset to the history self.upload_file( '1.bed' ) latest_dataset = get_latest_dataset() # Make sure DatasetPermissions are correct - default is 'manage permissions' dps = get_dataset_permissions_by_dataset( latest_dataset ) if len( dps ) > 1: raise AssertionError( '%d DatasetPermissions were created for dataset id %d when it was created ( should have been 1 )' % ( len( dps ), latest_dataset.id ) ) dp = dps[0] if not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action: raise AssertionError( 'The DatasetPermissions.action for dataset id %d is "%s", but it should be "manage permissions"' % ( latest_dataset.id, dp.action ) ) # Change DefaultHistoryPermissions for regular_user1 permissions_in = [] actions_in = [] for key, value in galaxy.model.Dataset.permitted_actions.items(): # Setting the 'access' permission with the private role makes this dataset private permissions_in.append( key ) actions_in.append( value.action ) # Sort actions for later comparison actions_in.sort() self.user_set_default_permissions( permissions_in=permissions_in, role_id=str( regular_user1_private_role.id ) ) # Make sure the default permissions are changed for new histories self.new_history() # logged in as regular_user1 latest_history = get_latest_history_for_user( regular_user1 ) if len( latest_history.default_permissions ) != len( actions_in ): raise AssertionError( '%d DefaultHistoryPermissions were created for history id %d, should have been %d' % ( len( latest_history.default_permissions ), latest_history.id, len( actions_in ) ) ) dhps = [] for dhp in latest_history.default_permissions: dhps.append( dhp.action ) # Sort permissions for later comparison dhps.sort() for key, value in galaxy.model.Dataset.permitted_actions.items(): if value.action not in dhps: raise AssertionError( '%s not in history id %d default_permissions after they were changed' % ( value.action, latest_history.id ) ) # Add a dataset to the history self.upload_file( '1.bed' ) latest_dataset = get_latest_dataset() # Make sure DatasetPermissions are correct if len( latest_dataset.actions ) != len( latest_history.default_permissions ): raise AssertionError( '%d DatasetPermissions were created for dataset id %d when it was created ( should have been %d )' % ( len( latest_dataset.actions ), latest_dataset.id, len( latest_history.default_permissions ) ) ) dps = [] for dp in latest_dataset.actions: dps.append( dp.action ) # Sort actions for later comparison dps.sort() # Compare DatasetPermissions with permissions_in - should be the same if dps != actions_in: raise AssertionError( 'DatasetPermissions "%s" for dataset id %d differ from changed default permissions "%s"' % ( str( dps ), latest_dataset.id, str( actions_in ) ) ) # Compare DefaultHistoryPermissions and DatasetPermissions - should be the same if dps != dhps: raise AssertionError( 'DatasetPermissions "%s" for dataset id %d differ from DefaultHistoryPermissions "%s" for history id %d' % ( str( dps ), latest_dataset.id, str( dhps ), latest_history.id ) )
def test_010_private_role_creation_and_default_history_permissions(self): """Testing private role creation and changing DefaultHistoryPermissions for new histories""" # Logged in as admin_user self.logout() # Some of the history related tests here are similar to some tests in the # test_history_functions.py script, so we could potentially eliminate 1 or 2 of them. self.login(email='*****@*****.**') global regular_user1 regular_user1 = get_user('*****@*****.**') assert regular_user1 is not None, 'Problem retrieving user with email "*****@*****.**" from the database' # Add a dataset to the history self.upload_file('1.bed') latest_dataset = get_latest_dataset() # Make sure DatasetPermissions are correct - default is 'manage permissions' dps = get_dataset_permissions_by_dataset(latest_dataset) if len(dps) > 1: raise AssertionError( '%d DatasetPermissions were created for dataset id %d when it was created ( should have been 1 )' \ % ( len( dps ), latest_dataset.id ) ) dp = dps[0] if not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action: raise AssertionError( 'The DatasetPermissions.action for dataset id %d is "%s", but it should be "manage permissions"' \ % ( latest_dataset.id, dp.action ) ) # Change DefaultHistoryPermissions for regular_user1 permissions_in = [] actions_in = [] for key, value in galaxy.model.Dataset.permitted_actions.items(): # Setting the 'access' permission with the private role makes this dataset private permissions_in.append(key) actions_in.append(value.action) # Sort actions for later comparison actions_in.sort() self.user_set_default_permissions(permissions_in=permissions_in, role_id=str( regular_user1_private_role.id)) # Make sure the default permissions are changed for new histories self.new_history() # logged in as regular_user1 latest_history = get_latest_history_for_user(regular_user1) if len(latest_history.default_permissions) != len(actions_in): raise AssertionError( '%d DefaultHistoryPermissions were created for history id %d, should have been %d' % \ ( len( latest_history.default_permissions ), latest_history.id, len( actions_in ) ) ) dhps = [] for dhp in latest_history.default_permissions: dhps.append(dhp.action) # Sort permissions for later comparison dhps.sort() for key, value in galaxy.model.Dataset.permitted_actions.items(): if value.action not in dhps: raise AssertionError( '%s not in history id %d default_permissions after they were changed' % (value.action, latest_history.id)) # Add a dataset to the history self.upload_file('1.bed') latest_dataset = get_latest_dataset() # Make sure DatasetPermissions are correct if len(latest_dataset.actions) != len( latest_history.default_permissions): raise AssertionError( '%d DatasetPermissions were created for dataset id %d when it was created ( should have been %d )' % \ ( len( latest_dataset.actions ), latest_dataset.id, len( latest_history.default_permissions ) ) ) dps = [] for dp in latest_dataset.actions: dps.append(dp.action) # Sort actions for later comparison dps.sort() # Compare DatasetPermissions with permissions_in - should be the same if dps != actions_in: raise AssertionError( 'DatasetPermissions "%s" for dataset id %d differ from changed default permissions "%s"' \ % ( str( dps ), latest_dataset.id, str( actions_in ) ) ) # Compare DefaultHistoryPermissions and DatasetPermissions - should be the same if dps != dhps: raise AssertionError( 'DatasetPermissions "%s" for dataset id %d differ from DefaultHistoryPermissions "%s" for history id %d' \ % ( str( dps ), latest_dataset.id, str( dhps ), latest_history.id ) )
def test_005_create_new_user_account_as_admin(self): """Testing creating a new user account as admin""" # Logged in as admin_user email = '*****@*****.**' password = '******' # Test setting the user name to one that is already taken. Note that the account must not exist in order # for this test to work as desired, so the email we're passing is important... previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email='*****@*****.**', password=password, username='******', redirect='') if not username_taken: error_msg = "The public name (%s) is already being used by another user, but no error was displayed" % 'admin-user' raise AssertionError(error_msg) # Test setting the user name to an invalid one. Note that the account must not exist in order # for this test to work as desired, so the email we're passing is important... previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email='*****@*****.**', password=password, username='******', redirect='') if not invalid_username: raise AssertionError( "The public name (%s) is is invalid, but no error was displayed" % '*****@*****.**') previously_created, username_taken, invalid_username = self.create_new_account_as_admin( email=email, password=password, username='******', redirect='') # Get the user object for later tests global regular_user3 regular_user3 = get_user(email) assert regular_user3 is not None, 'Problem retrieving user with email "%s" from the database' % email global regular_user3_private_role regular_user3_private_role = get_private_role(regular_user3) # Make sure DefaultUserPermissions were created if not regular_user3.default_permissions: raise AssertionError( 'No DefaultUserPermissions were created for user %s when the admin created the account' % email) # Make sure a private role was created for the user if not regular_user3.roles: raise AssertionError( 'No UserRoleAssociations were created for user %s when the admin created the account' % email) if not previously_created and len(regular_user3.roles) != 1: raise AssertionError( '%d UserRoleAssociations were created for user %s when the admin created the account ( should have been 1 )' % (len(regular_user3.roles), regular_user3.email)) for ura in regular_user3.roles: role = database_contexts.galaxy_context.query( galaxy.model.Role).get(ura.role_id) if not previously_created and role.type != 'private': raise AssertionError( 'Role created for user %s when the admin created the account is not private, type is' % str(role.type)) if not previously_created: # Make sure a history was not created ( previous test runs may have left deleted histories ) histories = get_all_histories_for_user(regular_user3) if histories: raise AssertionError( 'Histories were incorrectly created for user %s when the admin created the account' % email) # Make sure the user was not associated with any groups if regular_user3.groups: raise AssertionError( 'Groups were incorrectly associated with user %s when the admin created the account' % email)
def test_0000_create_users(self): self.logout() self.login(email='*****@*****.**') admin_user = test_db_util.get_user('*****@*****.**') assert admin_user is not None, 'Problem retrieving user with email "*****@*****.**" from the database'
def test_0000_create_users( self ): self.logout() self.login( email='*****@*****.**' ) admin_user = test_db_util.get_user( '*****@*****.**' ) assert admin_user is not None, 'Problem retrieving user with email "*****@*****.**" from the database'