mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
More bug fixes, functional tests for data security and libraries.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<td>
|
||||
<ul>
|
||||
%for role in roles:
|
||||
<li>${role.name}</li>
|
||||
<li>${role.description}</li>
|
||||
%endfor
|
||||
</ul>
|
||||
%if not anchored:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<tr>
|
||||
%endif
|
||||
<td>
|
||||
${role.name}
|
||||
${role.description}
|
||||
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">▼</a>
|
||||
<div popupmenu="role-${role.id}-popup">
|
||||
<a class="action-button" href="${h.url_for( action='undelete_role', role_id=role.id )}">Undelete</a>
|
||||
@@ -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 )}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
<td>
|
||||
%if not anchored:
|
||||
<div style="float: right;"><a href="#TOP">top</a></div>
|
||||
<a name="${curr_anchor}"><input type="checkbox" name="roles" value="${role.id}"/> ${role.name}</a>
|
||||
<a name="${curr_anchor}"><input type="checkbox" name="roles" value="${role.id}"/> ${role.description}</a>
|
||||
%else:
|
||||
<input type="checkbox" name="roles" value="${role.id}"/> ${role.name}
|
||||
<input type="checkbox" name="roles" value="${role.id}"/> ${role.description}
|
||||
%endif
|
||||
</td>
|
||||
</tr>
|
||||
@@ -77,10 +77,10 @@
|
||||
<% curr_anchor = 'A' %>
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
%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 )}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
%else:
|
||||
<input type="checkbox" name="members" value="${user.id}"/> ${user.email}
|
||||
%endif
|
||||
%if not anchored:
|
||||
<a name="${curr_anchor}"></a>
|
||||
<div style="float: right;"><a href="#TOP">top</a></div>
|
||||
%endif
|
||||
</td>
|
||||
</tr>
|
||||
</%def>
|
||||
@@ -41,7 +45,7 @@
|
||||
curr_anchor = 'A'
|
||||
%>
|
||||
<tr style="background: #EEE">
|
||||
<td style="border-bottom: 1px solid #D8B365; text-align: center;">
|
||||
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
|
||||
Jump to letter:
|
||||
%for a in anchors:
|
||||
| <a href="#${a}">${a}</a>
|
||||
@@ -94,4 +98,3 @@
|
||||
</table>
|
||||
</form>
|
||||
%endif
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
%endif
|
||||
<td>
|
||||
%if check:
|
||||
<input type="checkbox" name="roles" value="${role.id}" checked/> ${role.name}
|
||||
<input type="checkbox" name="roles" value="${role.id}" checked/> ${role.description}
|
||||
%else:
|
||||
<input type="checkbox" name="roles" value="${role.id}"/> ${role.name}
|
||||
<input type="checkbox" name="roles" value="${role.id}"/> ${role.description}
|
||||
%endif
|
||||
</td>
|
||||
</tr>
|
||||
@@ -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 )}
|
||||
|
||||
@@ -23,9 +23,7 @@
|
||||
<td>
|
||||
<ul>
|
||||
%for user in members:
|
||||
<li>
|
||||
<a href="${h.url_for( controller='admin', action='user', user_id=user.id )}">${user.email}</a>
|
||||
</li>
|
||||
<li><a href="${h.url_for( controller='admin', action='user', user_id=user.id )}">${user.email}</a></li>
|
||||
%endfor
|
||||
</ul>
|
||||
</td>
|
||||
@@ -34,9 +32,9 @@
|
||||
%for role in roles:
|
||||
<li>
|
||||
%if not role.type == galaxy.model.Role.types.PRIVATE:
|
||||
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.name}</a>
|
||||
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.description}</a>
|
||||
%else:
|
||||
${role.name}
|
||||
${role.description}
|
||||
%endif
|
||||
</li>
|
||||
%endfor
|
||||
@@ -76,7 +74,7 @@
|
||||
curr_anchor = 'A'
|
||||
%>
|
||||
<tr style="background: #EEE">
|
||||
<td colspan="3" style="text-align: center; border-bottom: 1px solid #D8B365">
|
||||
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
|
||||
Jump to letter:
|
||||
%for a in anchors:
|
||||
| <a href="#${a}">${a}</a>
|
||||
|
||||
@@ -48,29 +48,29 @@ $().ready(function() {
|
||||
%endif
|
||||
|
||||
<div class="toolForm">
|
||||
<div class="toolFormTitle">Role '${role.name}'</div>
|
||||
<div class="toolFormTitle">Role '${role.description}'</div>
|
||||
<div class="toolFormBody">
|
||||
<form name="associate_role_user_group" id="associate_role_user_group" action="${h.url_for( action='role_members_edit', role_id=role.id )}" method="post" >
|
||||
<div class="form-row">
|
||||
<div style="float: left; margin-right: 10px;">
|
||||
Users associated with '${role.name}'<br/>
|
||||
Users associated with '${role.description}'<br/>
|
||||
${render_select( "in_users", in_users )}<br/>
|
||||
<input type="submit" id="users_remove_button" value=">>"/>
|
||||
</div>
|
||||
<div>
|
||||
Users not associated with '${role.name}'<br/>
|
||||
Users not associated with '${role.description}'<br/>
|
||||
${render_select( "out_users", out_users )}<br/>
|
||||
<input type="submit" id="users_add_button" value="<<"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div style="float: left; margin-right: 10px;">
|
||||
Groups associated with '${role.name}'<br/>
|
||||
Groups associated with '${role.description}'<br/>
|
||||
${render_select( "in_groups", in_groups )}<br/>
|
||||
<input type="submit" id="groups_remove_button" value=">>"/>
|
||||
</div>
|
||||
<div>
|
||||
Groups not associated with '${role.name}'<br/>
|
||||
Groups not associated with '${role.description}'<br/>
|
||||
${render_select( "out_groups", out_groups )}<br/>
|
||||
<input type="submit" id="groups_add_button" value="<<"/>
|
||||
</div>
|
||||
@@ -84,7 +84,7 @@ $().ready(function() {
|
||||
<br clear="left"/>
|
||||
<br/>
|
||||
%if len( library_dataset_actions ) > 0:
|
||||
<h3>Library datasets associated with role '${role.name}'</h3>
|
||||
<h3>Library datasets associated with role '${role.description}'</h3>
|
||||
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<tr>
|
||||
%endif
|
||||
<td>
|
||||
${role.name}
|
||||
${role.description}
|
||||
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">▼</a>
|
||||
<div popupmenu="role-${role.id}-popup">
|
||||
<a class="action-button" href="${h.url_for( action='role', role_id=role.id )}">Change associated users and groups</a>
|
||||
@@ -84,10 +84,10 @@
|
||||
<td>Groups</td>
|
||||
</tr>
|
||||
%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 )}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<%def name="render_role( user, role )">
|
||||
<li>
|
||||
%if not role.type == galaxy.model.Role.types.PRIVATE:
|
||||
<a href="${h.url_for( action='role', role=role, edit=True )}">${role.name}</a>
|
||||
<a href="${h.url_for( action='role', role_id=role.id, edit=True )}">${role.description}</a>
|
||||
%else:
|
||||
${role.name}
|
||||
${role.description}
|
||||
%endif
|
||||
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">▼</a>
|
||||
<div popupmenu="role-${role.id}-popup">
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
%else:
|
||||
<input type="checkbox" name="groups" value="${group.id}"/> ${group.name}
|
||||
%endif
|
||||
%if not anchored:
|
||||
<a name="${curr_anchor}"></a>
|
||||
<div style="float: right;"><a href="#TOP">top</a></div>
|
||||
%endif
|
||||
</td>
|
||||
</tr>
|
||||
</%def>
|
||||
@@ -41,7 +45,7 @@
|
||||
curr_anchor = 'A'
|
||||
%>
|
||||
<tr style="background: #EEE">
|
||||
<td style="border-bottom: 1px solid #D8B365; text-align: center;">
|
||||
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
|
||||
Jump to letter:
|
||||
%for a in anchors:
|
||||
| <a href="#${a}">${a}</a>
|
||||
@@ -94,4 +98,3 @@
|
||||
</table>
|
||||
</form>
|
||||
%endif
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<td>
|
||||
<ul>
|
||||
%for role in roles:
|
||||
<li><a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.name}</a></li>
|
||||
<li><a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.description}</a></li>
|
||||
%endfor
|
||||
</ul>
|
||||
%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, '' )}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
<label>Restrict dataset access to specific roles:</label>
|
||||
<select name="roles" multiple="true" size="5">
|
||||
%for role in roles:
|
||||
<option value="${role.id}">${role.name}</option>
|
||||
<option value="${role.id}">${role.description}</option>
|
||||
%endfor
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
<li>${action.description}</li>
|
||||
<ul>
|
||||
%for role in roles:
|
||||
<li>${role.name}</li>
|
||||
<li>${role.description}</li>
|
||||
%endfor
|
||||
</ul>
|
||||
%endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
Roles associated:<br/>
|
||||
<select name="${action_key}_in" id="${action_key}_in_select" class="in_select" style="width: 200px; height: 150px;" multiple>
|
||||
%for role in in_roles:
|
||||
<option value="${role.id}">${role.name}</option>
|
||||
<option value="${role.id}">${role.description}</option>
|
||||
%endfor
|
||||
</select> <br/>
|
||||
<input type="submit" id="${action_key}_remove_button" class="role_remove_button" value=">>"/>
|
||||
@@ -20,7 +20,7 @@
|
||||
Roles not associated:<br/>
|
||||
<select name="${action_key}_out" id="${action_key}_out_select" style="width: 200px; height: 150px;" multiple>
|
||||
%for role in out_roles:
|
||||
<option value="${role.id}">${role.name}</option>
|
||||
<option value="${role.id}">${role.description}</option>
|
||||
%endfor
|
||||
</select> <br/>
|
||||
<input type="submit" id="${action_key}_add_button" class="role_add_button" value="<<"/>
|
||||
|
||||
+62
-20
@@ -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: <unprintable ParseError object> exception. Uncomment the following 3 lines
|
||||
# ParseError: <unprintable ParseError object> 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' )
|
||||
|
||||
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user