diff --git a/lib/galaxy/web/controllers/admin.py b/lib/galaxy/web/controllers/admin.py index 7ca8d20233f..8593d0f65f5 100644 --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -77,7 +77,7 @@ class Admin( BaseController ): name = params.name description = params.description if not name or not description: - msg = "Please enter a name and a description" + msg = "Enter a valid name and a description" trans.response.send_redirect( web.url_for( action='create_role', msg=msg, messagetype='error' ) ) elif trans.app.model.Role.filter_by( name=name ).first(): msg = "A role with that name already exists" @@ -307,7 +307,7 @@ class Admin( BaseController ): params = util.Params( kwd ) name = params.name if not name: - msg = "Please enter a name" + msg = "Enter a valid name" trans.response.send_redirect( web.url_for( action='create_group', msg=msg, messagetype='error' ) ) elif trans.app.model.Group.filter_by( name=name ).first(): msg = "A group with that name already exists" @@ -1087,9 +1087,8 @@ class Admin( BaseController ): else: return trans.fill_template( "/admin/library/dataset.mako", dataset=lfdas ) @web.expose + @web.require_admin def add_dataset_to_folder_from_history( self, trans, ids="", folder_id=None, **kwd ): - if not self.user_is_admin( trans ): - return trans.show_error_message( no_privilege_msg ) try: folder = trans.app.model.LibraryFolder.get( folder_id ) except: diff --git a/templates/admin/dataset_security/deleted_groups.mako b/templates/admin/dataset_security/deleted_groups.mako index 422c80073bd..1e0751e3dd2 100644 --- a/templates/admin/dataset_security/deleted_groups.mako +++ b/templates/admin/dataset_security/deleted_groups.mako @@ -26,7 +26,7 @@ %if not anchored: diff --git a/templates/admin/dataset_security/deleted_roles.mako b/templates/admin/dataset_security/deleted_roles.mako index 9975997d92e..64153e05e50 100644 --- a/templates/admin/dataset_security/deleted_roles.mako +++ b/templates/admin/dataset_security/deleted_roles.mako @@ -9,7 +9,7 @@ %endif - ${role.name} + ${role.description}
Undelete @@ -78,10 +78,10 @@ groups = role_tuple[1] users = role_tuple[2] %> - %if render_quick_find and not role.name.upper().startswith( curr_anchor ): + %if render_quick_find and not role.description.upper().startswith( curr_anchor ): <% anchored = False %> %endif - %if render_quick_find and role.name.upper().startswith( curr_anchor ): + %if render_quick_find and role.description.upper().startswith( curr_anchor ): %if not anchored: ${render_row( role, groups, users, ctr, anchored, curr_anchor )} <% anchored = True %> @@ -90,7 +90,7 @@ %endif %elif render_quick_find: %for anchor in anchors[ anchor_loc: ]: - %if role.name.upper().startswith( anchor ): + %if role.description.upper().startswith( anchor ): %if not anchored: <% curr_anchor = anchor %> ${render_row( role, groups, users, ctr, anchored, curr_anchor )} diff --git a/templates/admin/dataset_security/group_create.mako b/templates/admin/dataset_security/group_create.mako index a137eb33ebb..ef9bbd407af 100644 --- a/templates/admin/dataset_security/group_create.mako +++ b/templates/admin/dataset_security/group_create.mako @@ -22,9 +22,9 @@ %if not anchored:
top
- ${role.name} + ${role.description} %else: - ${role.name} + ${role.description} %endif @@ -77,10 +77,10 @@ <% curr_anchor = 'A' %> %for ctr, role in enumerate( roles ): - %if render_quick_find and not role.name.upper().startswith( curr_anchor ): + %if render_quick_find and not role.description.upper().startswith( curr_anchor ): <% anchored = False %> %endif - %if render_quick_find and role.name.upper().startswith( curr_anchor ): + %if render_quick_find and role.description.upper().startswith( curr_anchor ): %if not anchored: ${render_role_row( role, ctr, anchored, curr_anchor )} <% anchored = True %> @@ -89,7 +89,7 @@ %endif %elif render_quick_find: %for anchor in anchors[ anchor_loc: ]: - %if role.name.upper().startswith( anchor ): + %if role.description.upper().startswith( anchor ): %if not anchored: <% curr_anchor = anchor %> ${render_role_row( role, ctr, anchored, curr_anchor )} diff --git a/templates/admin/dataset_security/group_members_edit.mako b/templates/admin/dataset_security/group_members_edit.mako index eb669d0c125..67575a415a2 100644 --- a/templates/admin/dataset_security/group_members_edit.mako +++ b/templates/admin/dataset_security/group_members_edit.mako @@ -14,6 +14,10 @@ %else: ${user.email} %endif + %if not anchored: + +
top
+ %endif @@ -41,7 +45,7 @@ curr_anchor = 'A' %> -
+ Jump to letter: %for a in anchors: | ${a} @@ -94,4 +98,3 @@
%endif - diff --git a/templates/admin/dataset_security/group_roles_edit.mako b/templates/admin/dataset_security/group_roles_edit.mako index 69acf372fe3..f23bcc36a2c 100644 --- a/templates/admin/dataset_security/group_roles_edit.mako +++ b/templates/admin/dataset_security/group_roles_edit.mako @@ -10,9 +10,9 @@ %endif %if check: - ${role.name} + ${role.description} %else: - ${role.name} + ${role.description} %endif @@ -60,10 +60,10 @@ %> %endif %endfor - %if render_quick_find and not role.name.upper().startswith( curr_anchor ): + %if render_quick_find and not role.description.upper().startswith( curr_anchor ): <% anchored = False %> %endif - %if render_quick_find and role.name.upper().startswith( curr_anchor ): + %if render_quick_find and role.description.upper().startswith( curr_anchor ): %if not anchored: ${render_row( role, ctr, anchored, curr_anchor, check )} <% anchored = True %> @@ -72,7 +72,7 @@ %endif %elif render_quick_find: %for anchor in anchors[ anchor_loc: ]: - %if role.name.upper().startswith( anchor ): + %if role.description.upper().startswith( anchor ): %if not anchored: <% curr_anchor = anchor %> ${render_row( role, ctr, anchored, curr_anchor, check )} diff --git a/templates/admin/dataset_security/groups.mako b/templates/admin/dataset_security/groups.mako index 391aa727b1d..af8e7add914 100644 --- a/templates/admin/dataset_security/groups.mako +++ b/templates/admin/dataset_security/groups.mako @@ -23,9 +23,7 @@ @@ -34,9 +32,9 @@ %for role in roles:
  • %if not role.type == galaxy.model.Role.types.PRIVATE: - ${role.name} + ${role.description} %else: - ${role.name} + ${role.description} %endif
  • %endfor @@ -76,7 +74,7 @@ curr_anchor = 'A' %> - + Jump to letter: %for a in anchors: | ${a} diff --git a/templates/admin/dataset_security/role.mako b/templates/admin/dataset_security/role.mako index 63e9c450986..7d87f6fac90 100644 --- a/templates/admin/dataset_security/role.mako +++ b/templates/admin/dataset_security/role.mako @@ -48,29 +48,29 @@ $().ready(function() { %endif
    -
    Role '${role.name}'
    +
    Role '${role.description}'
    - Users associated with '${role.name}'
    + Users associated with '${role.description}'
    ${render_select( "in_users", in_users )}
    - Users not associated with '${role.name}'
    + Users not associated with '${role.description}'
    ${render_select( "out_users", out_users )}
    - Groups associated with '${role.name}'
    + Groups associated with '${role.description}'
    ${render_select( "in_groups", in_groups )}
    - Groups not associated with '${role.name}'
    + Groups not associated with '${role.description}'
    ${render_select( "out_groups", out_groups )}
    @@ -84,7 +84,7 @@ $().ready(function() {

    %if len( library_dataset_actions ) > 0: -

    Library datasets associated with role '${role.name}'

    +

    Library datasets associated with role '${role.description}'

    %endif %for ctr, role in enumerate( roles ): - %if render_quick_find and not role.name.upper().startswith( curr_anchor ): + %if render_quick_find and not role.description.upper().startswith( curr_anchor ): <% anchored = False %> %endif - %if render_quick_find and role.name.upper().startswith( curr_anchor ): + %if render_quick_find and role.description.upper().startswith( curr_anchor ): %if not anchored: ${render_row( role, ctr, anchored, curr_anchor )} <% anchored = True %> @@ -96,7 +96,7 @@ %endif %elif render_quick_find: %for anchor in anchors[ anchor_loc: ]: - %if role.name.upper().startswith( anchor ): + %if role.description.upper().startswith( anchor ): %if not anchored: <% curr_anchor = anchor %> ${render_row( role, ctr, anchored, curr_anchor )} diff --git a/templates/admin/dataset_security/user.mako b/templates/admin/dataset_security/user.mako index aff1479944a..90b1c2b61b3 100644 --- a/templates/admin/dataset_security/user.mako +++ b/templates/admin/dataset_security/user.mako @@ -9,9 +9,9 @@ <%def name="render_role( user, role )">
  • %if not role.type == galaxy.model.Role.types.PRIVATE: - ${role.name} + ${role.description} %else: - ${role.name} + ${role.description} %endif
    diff --git a/templates/admin/dataset_security/user_groups_edit.mako b/templates/admin/dataset_security/user_groups_edit.mako index fa27a1655d7..e10eb97e10a 100644 --- a/templates/admin/dataset_security/user_groups_edit.mako +++ b/templates/admin/dataset_security/user_groups_edit.mako @@ -14,6 +14,10 @@ %else: ${group.name} %endif + %if not anchored: + + + %endif @@ -41,7 +45,7 @@ curr_anchor = 'A' %>
  • -
    diff --git a/templates/admin/dataset_security/roles.mako b/templates/admin/dataset_security/roles.mako index 0e46ca82162..916bf0dd63a 100644 --- a/templates/admin/dataset_security/roles.mako +++ b/templates/admin/dataset_security/roles.mako @@ -13,7 +13,7 @@
    - ${role.name} + ${role.description} Groups
    + Jump to letter: %for a in anchors: | ${a} @@ -94,4 +98,3 @@
    %endif - diff --git a/templates/admin/dataset_security/users.mako b/templates/admin/dataset_security/users.mako index 8cf1434b7b4..8dc7f58367a 100644 --- a/templates/admin/dataset_security/users.mako +++ b/templates/admin/dataset_security/users.mako @@ -29,7 +29,7 @@ %if not anchored: @@ -97,19 +97,19 @@ %endif %elif render_quick_find: %for anchor in anchors[ anchor_loc: ]: - %if user.email.upper().startswith( anchor ): - %if not anchored: - <% curr_anchor = anchor %> - ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} - <% anchored = True %> - %else: - ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} - %endif - <% - anchor_loc = anchors.index( anchor ) - break - %> - %endif + %if user.email.upper().startswith( anchor ): + %if not anchored: + <% curr_anchor = anchor %> + ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} + <% anchored = True %> + %else: + ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} + %endif + <% + anchor_loc = anchors.index( anchor ) + break + %> + %endif %endfor %else: ${render_row( user, groups, roles, ctr, True, '' )} diff --git a/templates/admin/library/new_dataset.mako b/templates/admin/library/new_dataset.mako index 074d6e6f7ca..3888d629aee 100644 --- a/templates/admin/library/new_dataset.mako +++ b/templates/admin/library/new_dataset.mako @@ -93,7 +93,7 @@
    diff --git a/templates/dataset/edit_attributes.mako b/templates/dataset/edit_attributes.mako index fdee84f6a87..e5d44cbce6b 100644 --- a/templates/dataset/edit_attributes.mako +++ b/templates/dataset/edit_attributes.mako @@ -173,7 +173,7 @@
  • ${action.description}
    • %for role in roles: -
    • ${role.name}
    • +
    • ${role.description}
    • %endfor
    %endif diff --git a/templates/dataset/security_common.mako b/templates/dataset/security_common.mako index 2ebe99d157e..234e8b0a369 100644 --- a/templates/dataset/security_common.mako +++ b/templates/dataset/security_common.mako @@ -11,7 +11,7 @@ Roles associated:

    @@ -20,7 +20,7 @@ Roles not associated:

    diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index ab51a378605..08da005df79 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -368,19 +368,23 @@ class TwillTestCase( unittest.TestCase ): self.check_page_for_string( "User with that email already exists" ) except: self.check_page_for_string( "Now logged in as %s" %email ) - self.home() #Reset our URL for future tests + self.home() + # Make sure a new private role was created for the user + self.visit_page( "user/set_default_permissions" ) + self.check_page_for_string( email ) + self.home() def login( self, email='test@bx.psu.edu', password='testuser'): # test@bx.psu.edu is configured as an admin user self.create( email=email, password=password, confirm=password ) self.visit_page( "user/login?email=%s&password=%s" % (email, password) ) self.check_page_for_string( "Now logged in as %s" %email ) - self.home() #Reset our URL for future tests + self.home() def logout( self ): self.visit_page( "user/logout" ) self.check_page_for_string( "You are no longer logged in" ) - self.home() #Reset our URL for future tests + self.home() # Functions associated with browsers, cookies, HTML forms and page visits def check_page_for_string( self, patt ): @@ -548,26 +552,44 @@ class TwillTestCase( unittest.TestCase ): self.assertNotEqual(count, maxiter) # Dataset Security stuff - def create_role( self, name='New Test Role', description="Very cool new test role", user_ids=[], group_ids=[] ): + def create_role( self, name='New Test Role', description="Very cool new test role", user_ids=[], group_ids=[], private_role='' ): """Create a new role""" self.visit_url( "%s/admin/create_role" % self.url ) form = tc.show() self.check_page_for_string( "Create Role" ) - try: + try: + # Attempt to submit a blank form + tc.fv( "1", "name", "" ) + tc.fv( "1", "description", "" ) + tc.submit( "create_role_button" ) + self.last_page() + self.check_page_for_string( "Enter a valid name and a description" ) tc.fv( "1", "name", name ) tc.fv( "1", "description", description ) for user_id in user_ids: - tc.fv( "1", "3", user_id ) # form field 3 is the check box named 'users' + tc.fv( "1", "users", user_id ) for group_id in group_ids: - tc.fv( "1", "4", group_id ) # form field 4 is the check box named 'groups' + tc.fv( "1", "groups", group_id ) tc.submit( "create_role_button" ) + self.last_page() + check_str = 'The new role has been created with %d associated users and %d associated groups' % ( len( user_ids ), len( group_ids ) ) + self.check_page_for_string( check_str ) + if private_role: + # Make sure no private roles are displayed + try: + self.check_page_for_string( private_role ) + errmsg = 'Private role %s displayed on Non-private Roles page' % private_role + raise AssertionError( errmsg ) + except AssertionError: + # Reaching here is the behavior we want since no private roles should be displayed + pass except AssertionError, err: self.home() errmsg = 'Exception caught attempting to create role: %s' % str( err ) raise AssertionError( errmsg ) self.home() self.visit_page( "admin/roles" ) - self.check_page_for_string( name ) + self.check_page_for_string( description ) self.home() def mark_role_deleted( self, role_id ): """Mark a role as deleted""" @@ -594,12 +616,25 @@ class TwillTestCase( unittest.TestCase ): self.visit_url( "%s/admin/create_group" % self.url ) form = tc.show() self.check_page_for_string( "Create Group" ) - try: + # Make sure no private roles are displayed + try: + self.check_page_for_string( 'Private Role for' ) + errmsg = 'Private role displayed on Create Group page' + raise AssertionError( errmsg ) + except AssertionError: + # Reaching here is the behavior we want since no private roles should be displayed + pass + try: + # Attempt to submit a blank form + tc.fv( "1", "name", "" ) + tc.submit( "create_group_button" ) + self.last_page() + self.check_page_for_string( "Enter a valid name" ) tc.fv( "1", "name", name ) for user_id in user_ids: - tc.fv( "1", "2", user_id ) # form field 2 is the check box named 'members' + tc.fv( "1", "members", user_id ) for role_id in role_ids: - tc.fv( "1", "3", role_id ) # form field 3 is the check box named 'roles' + tc.fv( "1", "roles", role_id ) tc.submit( "create_group_button" ) except AssertionError, err: self.home() @@ -680,8 +715,14 @@ class TwillTestCase( unittest.TestCase ): self.visit_url( "%s/admin/library?rename=True&id=%s" % ( self.url, library_id ) ) self.last_page() self.check_page_for_string( 'Edit library name and description' ) - tc.fv( "1", "name", name ) # form field 1 is the field named name... - tc.fv( "1", "description", description ) # form field 2 is the field named description... + # Attempt to submit a blank form + tc.fv( "1", "name", "" ) + tc.fv( "1", "description", "" ) + tc.submit( "rename_library_button" ) + self.last_page() + self.check_page_for_string( 'Enter a valid name' ) + tc.fv( "1", "name", name ) + tc.fv( "1", "description", description ) if root_folder: tc.fv( "1", "root_folder", root_folder ) tc.submit( "rename_library_button" ) @@ -754,8 +795,9 @@ class TwillTestCase( unittest.TestCase ): self.home() raise AssertionError( 'Exception caught attempting to create add a dataset to a folder: %s' % str( err ) ) self.home() - def add_datasets_from_library_dir( self, folder_id, extension='auto', dbkey='hg18', roles=[] ): + def add_datasets_from_library_dir( self, folder_id, extension='auto', dbkey='hg18', roles_tuple=[] ): """Add a directory of datasets to a folder""" + # roles is a list of tuples: [ ( role_id, role_description ) ] try: self.visit_url( "%s/admin/dataset?folder_id=%s" % ( self.url, folder_id ) ) self.last_page() @@ -765,8 +807,8 @@ class TwillTestCase( unittest.TestCase ): tc.fv( "1", "dbkey", dbkey ) library_dir = "%s" % self.file_dir tc.fv( "1", "server_dir", "library" ) - for role_id in roles: - tc.fv( "1", "roles", role_id ) + for role_tuple in roles_tuple: + tc.fv( "1", "roles", role_tuple[0] ) tc.submit( "new_dataset_button" ) self.last_page() self.check_page_for_string( '3 new datasets added to the library ( each is selected below )' ) @@ -776,14 +818,14 @@ class TwillTestCase( unittest.TestCase ): tc.submit( "action_on_datasets_button" ) self.last_page() self.check_page_for_string( '( 3 of them )' ) - self.check_page_for_string( 'New Test Role' ) - self.check_page_for_string( 'Another Test Role' ) - tc.find( "update_roles" ) + for role_tuple in roles_tuple: + self.check_page_for_string( role_tuple[1] ) # NOTE: we cannot submit the form because of a bug in twill ( it cannot handle select lists # that include no option fields. Since the "manage permissions" and "edit metadata" select # lists have no options ( no roles associated ), submitting the form will throw a - # ParseError: exception. Uncomment the following 3 lines + # ParseError: exception. Uncomment the following 4 lines # when twill fixes this bug... + # tc.find( "update_roles" ) # tc.submit( "update_roles" ) # self.last_page() # self.check_page_for_string( 'Libraries' ) diff --git a/test/functional/test_security_and_libraries.py b/test/functional/test_security_and_libraries.py index 0c9e0ace5f6..ae154e79770 100644 --- a/test/functional/test_security_and_libraries.py +++ b/test/functional/test_security_and_libraries.py @@ -2,44 +2,45 @@ import galaxy.model from galaxy.model.orm import * from base.twilltestcase import * -security_msg = 'You must have Galaxy administrator privileges to use this feature.' +not_logged_in_security_msg = 'You must be an administrator to access this feature, and currently you are not logged in.' +logged_in_security_msg = 'You must be an administrator to access this feature.' class TestHistory( TwillTestCase ): def test_00_admin_features_when_not_logged_in( self ): """Testing admin_features when not logged in""" self.logout() self.visit_url( "%s/admin" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/reload_tool?tool_id=upload1" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/roles" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/create_role" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/new_role" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/role" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/groups" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/create_group" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/group_members_edit" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/update_group_members" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/users" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/library_browser" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/libraries" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/library" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/folder?id=1&new=True" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) self.visit_url( "%s/admin/dataset" % self.url ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( not_logged_in_security_msg ) def test_03_login_as_admin( self ): """Testing logging in as an admin user""" self.login( email='test@bx.psu.edu' ) #This is configured as our admin user @@ -55,6 +56,14 @@ class TestHistory( TwillTestCase ): break if not private_role_found: raise AssertionError( "Private role not found for user '%s'" % testuser1.email ) + # Make sure a DefaultUserPermission exists for the user + if not testuser1.default_permissions: + raise AssertionError( 'No DefaultUserPermissions were created for %s when their account was created' % testuser1.email ) + if len( testuser1.default_permissions ) > 1: + raise AssertionError( 'More than 1 DefaultUserPermissions were created for %s when their account was created' % testuser1.email ) + dup = galaxy.model.DefaultUserPermissions.filter( galaxy.model.DefaultUserPermissions.table.c.user_id==testuser1.id ).first() + if not dup.action == 'manage permissions': + raise AssertionError( 'The DefaultUserPermission.action for user "%s" is "%s", but it should be "manage permissions"' % ( testuser1.email, dup.action ) ) self.visit_url( "%s/admin/user?user_id=%s" % ( self.url, testuser1.id ) ) self.check_page_for_string( testuser1.email ) self.home() @@ -64,19 +73,23 @@ class TestHistory( TwillTestCase ): global testuser2 testuser2 = galaxy.model.User.filter( galaxy.model.User.table.c.email=='test2@bx.psu.edu' ).first() self.visit_page( "admin" ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( logged_in_security_msg ) + # NOTE: we cannot currently Set DefaultHistoryPermissions for this user + # because of a bug in twill where it is not able to handle select lists that + # include no options... self.logout() self.login( email='test3@bx.psu.edu' ) # This will not be an admin user global testuser3 testuser3 = galaxy.model.User.filter( galaxy.model.User.table.c.email=='test3@bx.psu.edu' ).first() self.visit_page( "admin" ) - self.check_page_for_string( security_msg ) + self.check_page_for_string( logged_in_security_msg ) self.logout() def test_06_create_role( self ): """Testing creating new non-private role with 2 members""" self.login( email=testuser1.email ) - self.create_role( user_ids=[ str( testuser1.id ), str( testuser2.id ) ] ) name = 'New Test Role' + description = 'Very cool new test role' + self.create_role( name=name, description=description, user_ids=[ str( testuser1.id ), str( testuser2.id ) ], private_role=testuser1.email ) # Get the role object for later tests global new_test_role new_test_role = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first() @@ -107,7 +120,12 @@ class TestHistory( TwillTestCase ): # with the role, then add tests in test_55_purge_role to make sure the association records are deleted # when the role is purged. name = 'Another Test Role' - self.create_role( name=name, user_ids=[ str( testuser1.id ) ], group_ids=[ str( another_test_group.id ) ] ) + description = 'Another cool new test role' + self.create_role( name=name, + description=description, + user_ids=[ str( testuser1.id ) ], + group_ids=[ str( another_test_group.id ) ], + private_role=testuser1.email ) # Get the role object for later tests global another_test_role another_test_role = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first() @@ -152,6 +170,17 @@ class TestHistory( TwillTestCase ): """Testing copying a dataset from the current history to a library root folder""" folder = library.root_folder self.add_dataset_to_folder_from_history( str( folder.id ) ) + # Now that we have a history and a dataset, we can test for ActionDatasetRoleAssociation - we're still logged in as testuser1. + # The default setting are "manage permissions" + last_dataset_created = galaxy.model.Dataset.query().order_by( desc( galaxy.model.Dataset.table.c.create_time ) ).first() + adras = galaxy.model.ActionDatasetRoleAssociation.filter( galaxy.model.ActionDatasetRoleAssociation.table.c.dataset_id==last_dataset_created.id ).all() + if not adras: + raise AssertionError( 'No ActionDatasetRoleAssociations created for dataset id: %d' % last_dataset_created.id ) + if len( adras ) > 1: + raise AssertionError( 'More than 1 ActionDatasetRoleAssociations created for dataset id: %d' % last_dataset_created.id ) + for adra in adras: + if not adra.action == 'manage permissions': + raise AssertionError( 'ActionDatasetRoleAssociation.action "%s" is not the DefaultHistoryPermission setting, which is "manage permissions"' % str( adra.action ) ) def test_33_add_new_folder( self ): """Testing adding a folder to a library root folder""" root_folder = library.root_folder @@ -166,7 +195,8 @@ class TestHistory( TwillTestCase ): self.check_page_for_string( "New Test Folder" ) def test_36_add_datasets_from_library_dir( self ): """Testing adding several datasets from library directory to sub-folder""" - self.add_datasets_from_library_dir( str( new_test_folder.id ), roles=[ str( new_test_role.id ) ] ) + roles_tuple = [ ( str( new_test_role.id ), new_test_role.description ) ] + self.add_datasets_from_library_dir( str( new_test_folder.id ), roles_tuple=roles_tuple ) def test_39_mark_group_deleted( self ): """Testing marking a group as deleted""" self.visit_page( "admin/groups" ) @@ -178,7 +208,7 @@ class TestHistory( TwillTestCase ): def test_45_mark_role_deleted( self ): """Testing marking a role as deleted""" self.visit_page( "admin/roles" ) - self.check_page_for_string( another_test_role.name ) + self.check_page_for_string( another_test_role.description ) self.mark_role_deleted( str( another_test_role.id ) ) def test_48_undelete_role( self ): """Testing undeleting a deleted role"""