@@ -54,7 +54,7 @@ def test_auth_settings_without_bearer(self):
5454
5555
5656class TestUpdateParamsForAuthWithBearerToken :
57- """Test that update_params_for_auth uses bearer token correctly ."""
57+ """Test that update_params_for_auth sends all configured auth headers ."""
5858
5959 def _make_endpoint (self , config , auth_schemes ):
6060 """Helper to create an Endpoint with given auth schemes."""
@@ -73,8 +73,8 @@ def _make_endpoint(self, config, auth_schemes):
7373 api_client = api_client ,
7474 )
7575
76- def test_bearer_sends_only_authorization_header (self ):
77- """When access_token is set and bearerAuth is in auth, only Authorization: Bearer is sent."""
76+ def test_all_auth_headers_sent_when_all_configured (self ):
77+ """When all credentials are set, all auth headers are sent."""
7878 config = Configuration (
7979 api_key = {"apiKeyAuth" : "test-api-key" , "appKeyAuth" : "test-app-key" },
8080 access_token = "ddpat_test_pat" ,
@@ -85,11 +85,11 @@ def test_bearer_sends_only_authorization_header(self):
8585 endpoint .update_params_for_auth (headers , queries )
8686
8787 assert headers ["Authorization" ] == "Bearer ddpat_test_pat"
88- assert "DD-API-KEY" not in headers
89- assert "DD-APPLICATION-KEY" not in headers
88+ assert headers [ "DD-API-KEY" ] == "test-api-key"
89+ assert headers [ "DD-APPLICATION-KEY" ] == "test-app-key"
9090
91- def test_bearer_without_api_keys (self ):
92- """Bearer token works even without any API keys configured."""
91+ def test_bearer_only (self ):
92+ """Bearer token works without any API keys configured."""
9393 config = Configuration (access_token = "ddpat_test_pat" )
9494 endpoint = self ._make_endpoint (config , ["apiKeyAuth" , "appKeyAuth" , "bearerAuth" ])
9595 headers = {}
@@ -100,21 +100,8 @@ def test_bearer_without_api_keys(self):
100100 assert "DD-API-KEY" not in headers
101101 assert "DD-APPLICATION-KEY" not in headers
102102
103- def test_no_bearer_when_not_in_endpoint_auth (self ):
104- """access_token set but endpoint doesn't declare bearerAuth — uses regular auth."""
105- config = Configuration (
106- api_key = {"apiKeyAuth" : "test-api-key" , "appKeyAuth" : "test-app-key" },
107- access_token = "ddpat_test_pat" ,
108- )
109- endpoint = self ._make_endpoint (config , ["apiKeyAuth" , "appKeyAuth" ])
110- headers = {}
111- queries = []
112- endpoint .update_params_for_auth (headers , queries )
113-
114- assert headers ["DD-API-KEY" ] == "test-api-key"
115- assert headers ["DD-APPLICATION-KEY" ] == "test-app-key"
116-
117- def test_regular_auth_without_bearer (self ):
103+ def test_api_keys_only (self ):
104+ """Regular auth works without bearer token."""
118105 config = Configuration (
119106 api_key = {"apiKeyAuth" : "test-api-key" , "appKeyAuth" : "test-app-key" },
120107 )
@@ -127,30 +114,17 @@ def test_regular_auth_without_bearer(self):
127114 assert headers ["DD-APPLICATION-KEY" ] == "test-app-key"
128115 assert "Authorization" not in headers
129116
130- def test_bearer_takes_priority_over_delegated_auth (self ):
131- """When both bearer token and delegated auth are configured, bearer wins."""
132-
133- class MockProvider (DelegatedTokenProvider ):
134- def authenticate (self , config , api_config ):
135- return DelegatedTokenCredentials (
136- org_uuid = "test-org" ,
137- delegated_token = "delegated-token-123" ,
138- delegated_proof = "proof" ,
139- expiration = datetime .now () + timedelta (minutes = 10 ),
140- )
141-
117+ def test_bearer_not_sent_when_not_in_endpoint_auth (self ):
118+ """access_token set but endpoint doesn't declare bearerAuth."""
142119 config = Configuration (
143120 api_key = {"apiKeyAuth" : "test-api-key" , "appKeyAuth" : "test-app-key" },
144121 access_token = "ddpat_test_pat" ,
145- delegated_auth_provider = MockProvider (),
146- delegated_auth_org_uuid = "test-org" ,
147122 )
148- endpoint = self ._make_endpoint (config , ["apiKeyAuth" , "appKeyAuth" , "bearerAuth" ])
123+ endpoint = self ._make_endpoint (config , ["apiKeyAuth" , "appKeyAuth" ])
149124 headers = {}
150125 queries = []
151126 endpoint .update_params_for_auth (headers , queries )
152127
153- # Bearer token takes priority
154- assert headers ["Authorization" ] == "Bearer ddpat_test_pat"
155- assert "DD-API-KEY" not in headers
156- assert "DD-APPLICATION-KEY" not in headers
128+ assert headers ["DD-API-KEY" ] == "test-api-key"
129+ assert headers ["DD-APPLICATION-KEY" ] == "test-app-key"
130+ assert "Authorization" not in headers
0 commit comments