Skip to content

Commit

Permalink
feat: enable self signed jwt for http (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 authored Sep 30, 2021
1 parent 0c40194 commit 5f87973
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
quota_project_id=client_options.quota_project_id,
client_info=client_info,
{% if "grpc" in opts.transport %}
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
{% endif %}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
Expand All @@ -227,9 +225,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
Expand All @@ -246,9 +242,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
Expand All @@ -275,9 +269,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
client_cert_source_for_mtls=None,
quota_project_id="octopus",
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [
Expand Down Expand Up @@ -323,9 +315,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
client_cert_source_for_mtls=expected_client_cert_source,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

# Check the case ADC client cert is provided. Whether client cert is used depends on
Expand All @@ -351,9 +341,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
client_cert_source_for_mtls=expected_client_cert_source,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

# Check the case client_cert_source and ADC client cert are not provided.
Expand All @@ -370,9 +358,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)


Expand Down Expand Up @@ -400,9 +386,7 @@ def test_{{ service.client_name|snake_case }}_client_options_scopes(client_class
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)

@pytest.mark.parametrize("client_class,transport_class,transport_name", [
Expand All @@ -429,9 +413,7 @@ def test_{{ service.client_name|snake_case }}_client_options_credentials_file(cl
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
{% if 'grpc' in opts.transport %}
always_use_jwt_access=True,
{% endif %}
)
{% if 'grpc' in opts.transport %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def export_assets(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def generate_access_token(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def list_buckets(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def delete_log(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def list_log_metrics(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,7 @@ def __init__(self, *,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def list_instances(self,
Expand Down

0 comments on commit 5f87973

Please sign in to comment.