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.api.test_authenticate

from urllib.parse import urljoin

from requests import get

from galaxy_test.base.api_util import baseauth_headers
from galaxy_test.base.decorators import requires_new_user
from galaxy_test.base.populators import skip_without_tool
from ._framework import ApiTestCase

TEST_USER_EMAIL = "auth_user_test@bx.psu.edu"
TEST_USER_PASSWORD = "testpassword1"


[docs]class TestAuthenticateApi(ApiTestCase):
[docs] @requires_new_user def test_auth(self): self._setup_user(TEST_USER_EMAIL, TEST_USER_PASSWORD) baseauth_url = self._api_url("authenticate/baseauth", use_key=False) headers = baseauth_headers(TEST_USER_EMAIL, TEST_USER_PASSWORD) auth_response = get(baseauth_url, headers=headers) self._assert_status_code_is(auth_response, 200) auth_dict = auth_response.json() self._assert_has_keys(auth_dict, "api_key") # Verify key... random_api_url = self._api_url("users", use_key=False) random_api_response = get(random_api_url, params=dict(key=auth_dict["api_key"])) self._assert_status_code_is(random_api_response, 200)
[docs] def test_anon_history_creation(self): # First request: # We don't create any histories, just return a session cookie response = get(self.url) cookie = {"galaxysession": response.cookies["galaxysession"]} # Check that we don't have any histories (API doesn't auto-create new histories) histories_response = get( urljoin( self.url, "api/histories", ) ) assert not histories_response.json() # Second request, we know client follows conventions by including cookies, # default history is created. get(self.url, cookies=cookie) second_histories_response = get( urljoin(self.url, "history/current_history_json"), cookies=cookie, ) assert second_histories_response.json()