|
25 | 25 | from gitpod._types import Omit
|
26 | 26 | from gitpod._models import BaseModel, FinalRequestOptions
|
27 | 27 | from gitpod._constants import RAW_RESPONSE_HEADER
|
28 |
| -from gitpod._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError |
| 28 | +from gitpod._exceptions import GitpodError, APIStatusError, APITimeoutError, APIResponseValidationError |
29 | 29 | from gitpod._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options
|
30 | 30 |
|
31 | 31 | from .utils import update_env
|
@@ -335,6 +335,16 @@ def test_default_headers_option(self) -> None:
|
335 | 335 | assert request.headers.get("x-foo") == "stainless"
|
336 | 336 | assert request.headers.get("x-stainless-lang") == "my-overriding-header"
|
337 | 337 |
|
| 338 | + def test_validate_headers(self) -> None: |
| 339 | + client = Gitpod(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True) |
| 340 | + request = client._build_request(FinalRequestOptions(method="get", url="/foo")) |
| 341 | + assert request.headers.get("Authorization") == f"Bearer {bearer_token}" |
| 342 | + |
| 343 | + with pytest.raises(GitpodError): |
| 344 | + with update_env(**{"GITPOD_API_KEY": Omit()}): |
| 345 | + client2 = Gitpod(base_url=base_url, bearer_token=None, _strict_response_validation=True) |
| 346 | + _ = client2 |
| 347 | + |
338 | 348 | def test_default_query_option(self) -> None:
|
339 | 349 | client = Gitpod(
|
340 | 350 | base_url=base_url,
|
@@ -1121,6 +1131,16 @@ def test_default_headers_option(self) -> None:
|
1121 | 1131 | assert request.headers.get("x-foo") == "stainless"
|
1122 | 1132 | assert request.headers.get("x-stainless-lang") == "my-overriding-header"
|
1123 | 1133 |
|
| 1134 | + def test_validate_headers(self) -> None: |
| 1135 | + client = AsyncGitpod(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=True) |
| 1136 | + request = client._build_request(FinalRequestOptions(method="get", url="/foo")) |
| 1137 | + assert request.headers.get("Authorization") == f"Bearer {bearer_token}" |
| 1138 | + |
| 1139 | + with pytest.raises(GitpodError): |
| 1140 | + with update_env(**{"GITPOD_API_KEY": Omit()}): |
| 1141 | + client2 = AsyncGitpod(base_url=base_url, bearer_token=None, _strict_response_validation=True) |
| 1142 | + _ = client2 |
| 1143 | + |
1124 | 1144 | def test_default_query_option(self) -> None:
|
1125 | 1145 | client = AsyncGitpod(
|
1126 | 1146 | base_url=base_url,
|
|
0 commit comments