Skip to content

Commit b6383a4

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
Make python fail properly on invalid header (#711)
* Fail properly when an invalid header is passed This change was lost in the template rebase. * Add test * Regenerate client from commit c0fb344 of spec repo Co-authored-by: Thomas Hervé <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 56c548d commit b6383a4

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.5.1.dev2",
7-
"regenerated": "2021-12-07 14:20:03.067544",
8-
"spec_repo_commit": "df97aef"
7+
"regenerated": "2021-12-07 15:59:00.380490",
8+
"spec_repo_commit": "c0fb344"
99
},
1010
"v2": {
1111
"apigentools_version": "1.5.1.dev2",
12-
"regenerated": "2021-12-07 14:20:03.592436",
13-
"spec_repo_commit": "df97aef"
12+
"regenerated": "2021-12-07 15:59:00.863160",
13+
"spec_repo_commit": "c0fb344"
1414
}
1515
}
1616
}

.generator/templates/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ class ApiClient(object):
622622
headers['Cookie'] = auth_setting['value']
623623
elif auth_setting['in'] == 'header':
624624
if auth_setting['type'] != 'http-signature':
625+
if auth_setting["value"] is None:
626+
raise ApiValueError("Invalid authentication token for {}".format(auth_setting["key"]))
625627
headers[auth_setting['key']] = auth_setting['value']
626628
{{#hasHttpSignatureMethods}}
627629
else:

src/datadog_api_client/v1/api_client.py

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v2/api_client.py

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_errors.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
from datadog_api_client.v1 import Configuration, ApiClient
4+
from datadog_api_client.v1.api import metrics_api
5+
from datadog_api_client.v1.exceptions import ApiValueError
6+
7+
8+
def test_invalid_header():
9+
configuration = Configuration()
10+
configuration.api_key["apiKeyAuth"] = None
11+
12+
with ApiClient(configuration) as api_client:
13+
api_instance = metrics_api.MetricsApi(api_client)
14+
with pytest.raises(ApiValueError):
15+
api_instance.get_metric_metadata("some_metric")

0 commit comments

Comments
 (0)