Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make python fail properly on invalid header #711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2021-12-07 14:20:03.067544",
"spec_repo_commit": "df97aef"
"regenerated": "2021-12-07 15:59:00.380490",
"spec_repo_commit": "c0fb344"
},
"v2": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2021-12-07 14:20:03.592436",
"spec_repo_commit": "df97aef"
"regenerated": "2021-12-07 15:59:00.863160",
"spec_repo_commit": "c0fb344"
}
}
}
2 changes: 2 additions & 0 deletions .generator/templates/api_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ class ApiClient(object):
headers['Cookie'] = auth_setting['value']
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
if auth_setting["value"] is None:
raise ApiValueError("Invalid authentication token for {}".format(auth_setting["key"]))
headers[auth_setting['key']] = auth_setting['value']
{{#hasHttpSignatureMethods}}
else:
Expand Down
2 changes: 2 additions & 0 deletions src/datadog_api_client/v1/api_client.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/api_client.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest

from datadog_api_client.v1 import Configuration, ApiClient
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.exceptions import ApiValueError


def test_invalid_header():
configuration = Configuration()
configuration.api_key["apiKeyAuth"] = None

with ApiClient(configuration) as api_client:
api_instance = metrics_api.MetricsApi(api_client)
with pytest.raises(ApiValueError):
api_instance.get_metric_metadata("some_metric")