Warning
This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
Source code for galaxy_test.selenium.test_history_sharing
from .framework import (
selenium_only,
selenium_test,
SeleniumTestCase,
)
# Remove hack when submit_login works more consistently.
VALID_LOGIN_RETRIES = 3
[docs]
class TestHistorySharing(SeleniumTestCase):
[docs]
@selenium_test
def test_sharing_valid(self):
user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history()
self.submit_login(user2_email, retries=VALID_LOGIN_RETRIES)
response = self.api_get(f"histories/{history_id}", raw=True)
assert response.status_code == 200, response.text
[docs]
@selenium_test
def test_sharing_valid_by_id(self):
user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history(share_by_id=True)
self.submit_login(user2_email, retries=VALID_LOGIN_RETRIES)
response = self.api_get(f"histories/{history_id}", raw=True)
assert response.status_code == 200, response.text
[docs]
@selenium_test
def test_unsharing(self):
user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history()
self.submit_login(user1_email, retries=VALID_LOGIN_RETRIES)
self.home()
self.click_history_option_sharing()
sharing = self.components.histories.sharing
self.share_unshare_with_user(sharing, user2_email)
self.home()
self.click_history_option_sharing()
self.share_ensure_by_user_available(sharing)
unshare_user_button = sharing.unshare_with_user_button(email=user2_email)
unshare_user_button.assert_absent()
self.logout_if_needed()
self.submit_login(user2_email, retries=VALID_LOGIN_RETRIES)
response = self.api_get(f"histories/{history_id}", raw=True)
assert response.status_code == 403
[docs]
@selenium_test
def test_sharing_with_invalid_user(self):
user1_email = self._get_random_email()
self.register(user1_email)
self.share_history_with_user(user_email="invalid_user@test.com")
self.assert_error_message(contains="is not a valid Galaxy user")
self.screenshot("history_sharing_invalid_user")
[docs]
@selenium_test
def test_sharing_with_self(self):
user1_email = self._get_random_email()
self.register(user1_email)
self.share_history_with_user(user_email=user1_email)
self.assert_error_message(contains="You cannot share resources with yourself")
self.screenshot("history_sharing_invalid_with_self")
[docs]
class TestPrivateHistorySharingRequiresPermissionChanges(SeleniumTestCase):
"""Test that sharing private histories requires permission changes.
Includes regression test for PR #20886: When sharing a history containing private datasets
with another user, the default option should be "Make datasets private to
me and users this history is shared with" rather than "Make datasets public".
"""
[docs]
@selenium_test
def test_sharing_private_history_default_permission(self):
# Create two test users - one to own the history, one to share with
user1_email = self._get_random_email()
user2_email = self._get_random_email()
# Register first user and create a private history with data
self.register(user1_email)
self.make_history_private()
self.perform_upload_of_pasted_content("hello world")
self.wait_for_history()
# Register second user (must exist to share with)
self.logout_if_needed()
self.register(user2_email)
self.logout_if_needed()
# Login as first user and initiate sharing
self.submit_login(user1_email)
self.home()
self.click_history_option_sharing()
# Share with the second user - this triggers the permission dialog
sharing = self.components.histories.sharing
self.share_with_user(sharing, user_email=user2_email)
# Verify the permission change required dialog appears
self.screenshot("history_private_sharing_permissions_dialog")
self.components.histories.sharing.permissions_change_required.wait_for_visible()
# Verify the default selected option is 'make_accessible_to_shared'
element = self.components.histories.sharing.permissions_change_required_how.wait_for_visible()
default_value = element.get_attribute("value")
assert default_value == "make_accessible_to_shared", (
f"Expected default permission option to be 'make_accessible_to_shared' "
f"(private to shared users), but got '{default_value}'"
)
# Confirm the permission change to complete sharing
self.components.histories.sharing.permissions_change_required_ok.wait_for_and_click()
self.screenshot("history_private_sharing_permissions_confirmed")