Ejemplo n.º 1
0
def test_get_auth_metadata_plugin_oauth_should_pass(post, config_oauth):
    auth_metadata_plugin = get_auth_metadata_plugin(config_oauth)
    assert isinstance(auth_metadata_plugin, OAuthMetadataPlugin)
    assert post.call_count == 1
    assert post.call_args == call(AUTH_URL, headers=HEADERS, data=DATA)
    assert auth_metadata_plugin.get_signed_meta() == (("authorization",
                                                       "Bearer mock_token"), )
Ejemplo n.º 2
0
Archivo: client.py Proyecto: beoy/feast
    def __init__(self, options: Optional[Dict[str, str]] = None, **kwargs):
        """
        The Feast Client should be initialized with at least one service url
        Please see constants.py for configuration options. Commonly used options
        or arguments include:
            core_url: Feast Core URL. Used to manage features
            serving_url: Feast Serving URL. Used to retrieve features
            project: Sets the active project. This field is optional.
            core_secure: Use client-side SSL/TLS for Core gRPC API
            serving_secure: Use client-side SSL/TLS for Serving gRPC API
            enable_auth: Enable authentication and authorization
            auth_provider: Authentication provider – "google" or "oauth"
            if auth_provider is "oauth", the following fields are mandatory –
            oauth_grant_type, oauth_client_id, oauth_client_secret, oauth_audience, oauth_token_request_url

        Args:
            options: Configuration options to initialize client with
            **kwargs: Additional keyword arguments that will be used as
                configuration options along with "options"
        """

        if options is None:
            options = dict()
        self._config = Config(options={**options, **kwargs})

        self._core_service_stub: Optional[CoreServiceStub] = None
        self._serving_service_stub: Optional[ServingServiceStub] = None
        self._auth_metadata: Optional[grpc.AuthMetadataPlugin] = None

        # Configure Auth Metadata Plugin if auth is enabled
        if self._config.getboolean(CONFIG_ENABLE_AUTH_KEY):
            self._auth_metadata = feast_auth.get_auth_metadata_plugin(self._config)
Ejemplo n.º 3
0
    def __init__(self, options=None, **kwargs):
        """
        JobControllerClient should be initialized with
            jobcontroller_url: Feast JobController address

        :param options: Configuration options to initialize client with
        :param kwargs: options in kwargs style
        """
        if options is None:
            options = dict()
        self._config = Config(options={**options, **kwargs})

        self._jobcontroller_service_stub: Optional[
            JobControllerServiceStub] = None
        self._auth_metadata: Optional[grpc.AuthMetadataPlugin] = None

        # Configure Auth Metadata Plugin if auth is enabled
        if self._config.getboolean(CONFIG_ENABLE_AUTH_KEY):
            self._auth_metadata = feast_auth.get_auth_metadata_plugin(
                self._config)
Ejemplo n.º 4
0
def test_get_auth_metadata_plugin_google_should_raise_when_token_validation_fails(
        subprocess, default, config_google):
    with raises(RuntimeError):
        get_auth_metadata_plugin(config_google)
Ejemplo n.º 5
0
def test_get_auth_metadata_plugin_google_should_pass_with_token_from_google_auth_lib(
        subprocess, default, config_google):
    auth_metadata_plugin = get_auth_metadata_plugin(config_google)
    assert isinstance(auth_metadata_plugin, GoogleOpenIDAuthMetadataPlugin)
    assert auth_metadata_plugin.get_signed_meta() == (("authorization",
                                                       "Bearer fake_token"), )
Ejemplo n.º 6
0
def test_get_auth_metadata_plugin_google_should_pass_with_token_from_gcloud_sdk(
        subprocess, jwt, config_google):
    auth_metadata_plugin = get_auth_metadata_plugin(config_google)
    assert isinstance(auth_metadata_plugin, GoogleOpenIDAuthMetadataPlugin)
    assert auth_metadata_plugin.get_signed_meta() == (("authorization",
                                                       "Bearer std_output"), )
Ejemplo n.º 7
0
def test_get_auth_metadata_plugin_oauth_should_raise_when_config_is_incorrect(
    config_with_missing_variable, ):
    with raises(RuntimeError):
        get_auth_metadata_plugin(config_with_missing_variable)
Ejemplo n.º 8
0
def test_get_auth_metadata_plugin_oauth_should_raise_when_response_is_not_200(
        post, config_oauth):
    with raises(RuntimeError):
        get_auth_metadata_plugin(config_oauth)
        assert post.call_count == 1
        assert post.call_args == call(AUTH_URL, headers=HEADERS, data=DATA)
Ejemplo n.º 9
0
def test_get_auth_metadata_plugin_google_should_pass_with_token_from_gcloud_sdk(
        verify_token, fetch_id_token, config_google):
    auth_metadata_plugin = get_auth_metadata_plugin(config_google)
    assert isinstance(auth_metadata_plugin, GoogleOpenIDAuthMetadataPlugin)
    assert auth_metadata_plugin.get_signed_meta() == (("authorization",
                                                       "Bearer Some Token"), )