Esempio n. 1
0
def flask_helpers_noauth():
    """
    A fixture designed to mock the Globus Auth integration in an Flask app
    created using the api_helpers. Simply using this fixture will allow creating
    the mocked app.
    """
    with patch(
            "globus_action_provider_tools.flask.api_helpers.TokenChecker.check_token",
            return_value=mock_authstate(),
    ):
        yield
Esempio n. 2
0
import warnings
from unittest.mock import patch

from globus_action_provider_tools.testing.mocks import mock_authstate

warnings.warn(
    ("The globus_action_provider_tools.testing.patches module is deprecated and will "
     "be removed in 0.12.0. Please consider using the "
     "globus_action_provider_tools.testing.fixtures module instead."),
    DeprecationWarning,
    stacklevel=2,
)

flask_api_helpers_tokenchecker_patch = patch(
    "globus_action_provider_tools.flask.api_helpers.TokenChecker.check_token",
    return_value=mock_authstate(),
)

flask_blueprint_tokenchecker_patch = patch(
    "globus_action_provider_tools.flask.apt_blueprint.TokenChecker.check_token",
    return_value=mock_authstate(),
)
Esempio n. 3
0
def test_authstate_is_specced():
    authstate = mock_authstate()
    with pytest.raises(AttributeError):
        authstate.not_a_valid_method()
Esempio n. 4
0
def test_mocked_tokenchecker_creates_mocked_authstate():
    assert (mock_authstate().effective_identity ==
            mock_tokenchecker().check_token().effective_identity)
Esempio n. 5
0
def test_create_mocked_authstate():
    auth = mock_authstate("", "not_a_secret", bogus_kwarg="sure")

    assert auth is not None
    assert isinstance(auth, AuthState)