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_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_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 )
Example #7
0
 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_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
                         ])
Example #12
0
    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)