def test_010_user_reqistration_single_user_info_forms(self): ''' Testing user registration with a single user info form ''' # lets delete the 'Researcher' user info form self.login('*****@*****.**') form_two_latest = get_latest_form(form_two_name) form_two_latest.current.deleted = True sa_session.add(form_two_latest.current) sa_session.flush() self.home() self.visit_page('forms/manage?sort=create_time&f-deleted=True') self.check_page_for_string(form_two_latest.name) self.logout() # user a new user with 'Student' user info form form_one = get_latest_form(form_one_name) user_info_values = ['Educational', 'Penn State', True] self.create_user_with_info('*****@*****.**', 'testuser', 'test12', user_info_forms='single', user_info_form_id=form_one.id, user_info_values=user_info_values) self.home() self.visit_page("user/show_info") self.check_page_for_string("Manage User Information") self.check_page_for_string(user_info_values[0]) self.check_page_for_string(user_info_values[1]) self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>')
def test_045_change_permissions_on_current_history(self): """Testing changing permissions on the current history""" # Logged in as regular_user3 self.logout() self.login(email=admin_user.email) # Current history is history4 self.new_history() global history5 history5 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history5 is not None, "Problem retrieving history5 from database" self.rename_history(self.security.encode_id(history5.id), history5.name, new_name=urllib.quote("history 5")) # Current history is hostory5 sa_session.refresh(history5) # Due to the limitations of twill ( not functional with the permissions forms ), we're forced # to do this manually. At this point, we just want to restrict the access permission on history5 # to the admin_user global access_action access_action = galaxy.model.Dataset.permitted_actions.DATASET_ACCESS.action dhp = galaxy.model.DefaultHistoryPermissions(history5, access_action, admin_user_private_role) sa_session.add(dhp) sa_session.flush() sa_session.refresh(history5) global history5_default_permissions history5_default_permissions = [dhp.action for dhp in history5.default_permissions] # Sort for later comparison history5_default_permissions.sort() self.upload_file("1.bed", dbkey="hg18") history5_dataset1 = None for hda in history5.datasets: if hda.name == "1.bed": history5_dataset1 = hda.dataset break assert history5_dataset1 is not None, "Problem retrieving history5_dataset1 from the database" # The permissions on the dataset should be restricted from sharing with anyone due to the # inherited history permissions dataset_permissions = [a.action for a in history5_dataset1.actions] dataset_permissions.sort() if dataset_permissions != history5_default_permissions: err_msg = ( "Dataset permissions for history5_dataset1 (%s) were not correctly inherited from history permissions (%s)" % (str(dataset_permissions), str(history5_default_permissions)) ) raise AssertionError, err_msg # Make sure when we logout and login, the history default permissions are preserved self.logout() self.login(email=admin_user.email) sa_session.refresh(history5) current_history_permissions = [dhp.action for dhp in history5.default_permissions] current_history_permissions.sort() if current_history_permissions != history5_default_permissions: raise AssertionError, "With logout and login, the history default permissions are not preserved"
def test_010_user_reqistration_single_user_info_forms( self ): ''' Testing user registration with a single user info form ''' # lets delete the 'Researcher' user info form self.login( '*****@*****.**' ) form_two_latest = get_latest_form(form_two_name) form_two_latest.current.deleted = True sa_session.add( form_two_latest.current ) sa_session.flush() self.home() self.visit_page('forms/manage?sort=create_time&f-deleted=True') self.check_page_for_string(form_two_latest.name) self.logout() # user a new user with 'Student' user info form form_one = get_latest_form(form_one_name) user_info_values=['Educational', 'Penn State', True] self.create_user_with_info( '*****@*****.**', 'testuser', 'test12', user_info_forms='single', user_info_form_id=form_one.id, user_info_values=user_info_values ) self.home() self.visit_page( "user/show_info" ) self.check_page_for_string( "Manage User Information" ) self.check_page_for_string( user_info_values[0] ) self.check_page_for_string( user_info_values[1] ) self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>' )
def test_020_create_user_as_admin( self ): ''' Testing creating users as an admin ''' self.logout() self.login( '*****@*****.**' ) form_one = get_latest_form(form_one_name) user_info_values=['Educational', 'Penn State', True] self.create_user_with_info( '*****@*****.**', 'testuser', 'test13', user_info_forms='single', user_info_form_id=form_one.id, user_info_values=user_info_values ) self.logout() self.login( '*****@*****.**' ) user = sa_session.query( galaxy.model.User ) \ .filter( and_( galaxy.model.User.table.c.email=='*****@*****.**' ) ).first() self.home() page = "admin/users?id=%s&operation=information&f-deleted=False" % self.security.encode_id( user.id ) self.visit_page( page ) self.check_page_for_string( 'Manage User Information' ) self.check_page_for_string( '*****@*****.**' ) self.check_page_for_string( user_info_values[0] ) self.check_page_for_string( user_info_values[1] ) self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>' ) # lets delete the 'Student' user info form self.login( '*****@*****.**' ) form_one_latest = get_latest_form(form_one_name) form_one_latest.current.deleted = True sa_session.add( form_one_latest.current ) sa_session.flush() self.home() self.visit_page('forms/manage?sort=create_time&f-deleted=True') self.check_page_for_string(form_one_latest.name) self.logout()
def test_020_create_user_as_admin(self): ''' Testing creating users as an admin ''' self.logout() self.login('*****@*****.**') form_one = get_latest_form(form_one_name) user_info_values = ['Educational', 'Penn State', True] self.create_user_with_info('*****@*****.**', 'testuser', 'test13', user_info_forms='single', user_info_form_id=form_one.id, user_info_values=user_info_values) self.logout() self.login('*****@*****.**') user = sa_session.query( galaxy.model.User ) \ .filter( and_( galaxy.model.User.table.c.email=='*****@*****.**' ) ).first() self.home() page = "admin/users?id=%s&operation=information&f-deleted=False" % self.security.encode_id( user.id) self.visit_page(page) self.check_page_for_string('Manage User Information') self.check_page_for_string('*****@*****.**') self.check_page_for_string(user_info_values[0]) self.check_page_for_string(user_info_values[1]) self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>') # lets delete the 'Student' user info form self.login('*****@*****.**') form_one_latest = get_latest_form(form_one_name) form_one_latest.current.deleted = True sa_session.add(form_one_latest.current) sa_session.flush() self.home() self.visit_page('forms/manage?sort=create_time&f-deleted=True') self.check_page_for_string(form_one_latest.name) self.logout()
def mark_obj_deleted(obj): obj.deleted = True sa_session.add(obj) sa_session.flush()
def flush(obj): sa_session.add(obj) sa_session.flush()
def flush( obj ): sa_session.add( obj ) sa_session.flush()
def mark_obj_deleted( obj ): obj.deleted = True sa_session.add( obj ) sa_session.flush()