Skip to content

Commit 1e67c3e

Browse files
committed
[Identity] Rename use_token_proxy
Signed-off-by: Paul Van Eck <[email protected]>
1 parent 091529b commit 1e67c3e

File tree

5 files changed

+54
-50
lines changed

5 files changed

+54
-50
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
### Breaking Changes
88

9+
> These changes do not impact the API of stable versions such as 1.25.1.
10+
> Only code written against beta version 1.26.0b1 is affected.
11+
- Renamed `use_token_proxy` keyword argument to `enable_azure_proxy` in `WorkloadIdentityCredential` to better reflect its purpose. ([#44147](https://github.com/Azure/azure-sdk-for-python/pull/44147))
12+
913
### Bugs Fixed
1014

1115
### Other Changes

sdk/identity/azure-identity/azure/identity/_credentials/workload_identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(
105105

106106
self._token_file_path = token_file_path
107107

108-
if kwargs.pop("use_token_proxy", False) and not within_credential_chain.get():
108+
if kwargs.pop("enable_azure_proxy", False) and not within_credential_chain.get():
109109
token_proxy_endpoint = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_TOKEN_PROXY)
110110
sni = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_SNI_NAME)
111111
ca_file = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_CA_FILE)

sdk/identity/azure-identity/azure/identity/aio/_credentials/workload_identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(
8181

8282
self._token_file_path = token_file_path
8383

84-
if kwargs.pop("use_token_proxy", False) and not within_credential_chain.get():
84+
if kwargs.pop("enable_azure_proxy", False) and not within_credential_chain.get():
8585
token_proxy_endpoint = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_TOKEN_PROXY)
8686
sni = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_SNI_NAME)
8787
ca_file = os.environ.get(EnvironmentVariables.AZURE_KUBERNETES_CA_FILE)

sdk/identity/azure-identity/tests/test_workload_identity_credential.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def send(request, **kwargs):
6565

6666

6767
class TestWorkloadIdentityCredentialTokenProxy:
68-
"""Test cases for WorkloadIdentityCredential with use_token_proxy=True."""
68+
"""Test cases for WorkloadIdentityCredential with enable_azure_proxy=True."""
6969

70-
def test_use_token_proxy_creates_custom_transport(self):
71-
"""Test that use_token_proxy=True creates a custom transport with correct parameters."""
70+
def test_enable_azure_proxy_creates_custom_transport(self):
71+
"""Test that enable_azure_proxy=True creates a custom transport with correct parameters."""
7272
tenant_id = "tenant-id"
7373
client_id = "client-id"
7474
token_file_path = "foo-path"
@@ -91,7 +91,7 @@ def test_use_token_proxy_creates_custom_transport(self):
9191
tenant_id=tenant_id,
9292
client_id=client_id,
9393
token_file_path=token_file_path,
94-
use_token_proxy=True,
94+
enable_azure_proxy=True,
9595
)
9696

9797
mock_get_transport.assert_called_once_with(
@@ -101,8 +101,8 @@ def test_use_token_proxy_creates_custom_transport(self):
101101
ca_data=None,
102102
)
103103

104-
def test_use_token_proxy_with_ca_data(self):
105-
"""Test use_token_proxy with CA data instead of CA file."""
104+
def test_enable_azure_proxy_with_ca_data(self):
105+
"""Test enable_azure_proxy with CA data instead of CA file."""
106106
tenant_id = "tenant-id"
107107
client_id = "client-id"
108108
token_file_path = "foo-path"
@@ -123,7 +123,7 @@ def test_use_token_proxy_with_ca_data(self):
123123
tenant_id=tenant_id,
124124
client_id=client_id,
125125
token_file_path=token_file_path,
126-
use_token_proxy=True,
126+
enable_azure_proxy=True,
127127
)
128128

129129
mock_get_transport.assert_called_once_with(
@@ -133,8 +133,8 @@ def test_use_token_proxy_with_ca_data(self):
133133
ca_data=ca_data,
134134
)
135135

136-
def test_use_token_proxy_minimal_config(self):
137-
"""Test use_token_proxy with minimal configuration (only proxy endpoint)."""
136+
def test_enable_azure_proxy_minimal_config(self):
137+
"""Test enable_azure_proxy with minimal configuration (only proxy endpoint)."""
138138
tenant_id = "tenant-id"
139139
client_id = "client-id"
140140
token_file_path = "foo-path"
@@ -153,7 +153,7 @@ def test_use_token_proxy_minimal_config(self):
153153
tenant_id=tenant_id,
154154
client_id=client_id,
155155
token_file_path=token_file_path,
156-
use_token_proxy=True,
156+
enable_azure_proxy=True,
157157
)
158158

159159
mock_get_transport.assert_called_once_with(
@@ -163,8 +163,8 @@ def test_use_token_proxy_minimal_config(self):
163163
ca_data=None,
164164
)
165165

166-
def test_use_token_proxy_missing_proxy_endpoint(self):
167-
"""Test that use_token_proxy=True without proxy endpoint uses the normal transport."""
166+
def test_enable_azure_proxy_missing_proxy_endpoint(self):
167+
"""Test that enable_azure_proxy=True without proxy endpoint uses the normal transport."""
168168
tenant_id = "tenant-id"
169169
client_id = "client-id"
170170
token_file_path = "foo-path"
@@ -179,11 +179,11 @@ def test_use_token_proxy_missing_proxy_endpoint(self):
179179
tenant_id=tenant_id,
180180
client_id=client_id,
181181
token_file_path=token_file_path,
182-
use_token_proxy=True,
182+
enable_azure_proxy=True,
183183
)
184184
mock_get_transport.assert_not_called()
185185

186-
def test_use_token_proxy_both_ca_file_and_data_raises_error(self):
186+
def test_enable_azure_proxy_both_ca_file_and_data_raises_error(self):
187187
"""Test that setting both CA file and CA data raises ValueError."""
188188
tenant_id = "tenant-id"
189189
client_id = "client-id"
@@ -204,11 +204,11 @@ def test_use_token_proxy_both_ca_file_and_data_raises_error(self):
204204
tenant_id=tenant_id,
205205
client_id=client_id,
206206
token_file_path=token_file_path,
207-
use_token_proxy=True,
207+
enable_azure_proxy=True,
208208
)
209209

210-
def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self):
211-
"""Test that use_token_proxy=True without proxy endpoint but with other custom env vars raises ValueError."""
210+
def test_enable_azure_proxy_missing_endpoint_with_custom_env_vars_raises_error(self):
211+
"""Test that enable_azure_proxy=True without proxy endpoint but with other custom env vars raises ValueError."""
212212
tenant_id = "tenant-id"
213213
client_id = "client-id"
214214
token_file_path = "foo-path"
@@ -230,7 +230,7 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
230230
tenant_id=tenant_id,
231231
client_id=client_id,
232232
token_file_path=token_file_path,
233-
use_token_proxy=True,
233+
enable_azure_proxy=True,
234234
)
235235

236236
# Test with CA file set but no proxy endpoint
@@ -243,7 +243,7 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
243243
tenant_id=tenant_id,
244244
client_id=client_id,
245245
token_file_path=token_file_path,
246-
use_token_proxy=True,
246+
enable_azure_proxy=True,
247247
)
248248

249249
# Test with CA data set but no proxy endpoint
@@ -256,11 +256,11 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
256256
tenant_id=tenant_id,
257257
client_id=client_id,
258258
token_file_path=token_file_path,
259-
use_token_proxy=True,
259+
enable_azure_proxy=True,
260260
)
261261

262-
def test_use_token_proxy_false_does_not_create_transport(self):
263-
"""Test that use_token_proxy=False (default) does not create a custom transport."""
262+
def test_enable_azure_proxy_false_does_not_create_transport(self):
263+
"""Test that enable_azure_proxy=False (default) does not create a custom transport."""
264264
tenant_id = "tenant-id"
265265
client_id = "client-id"
266266
token_file_path = "foo-path"
@@ -270,7 +270,7 @@ def test_use_token_proxy_false_does_not_create_transport(self):
270270
tenant_id=tenant_id,
271271
client_id=client_id,
272272
token_file_path=token_file_path,
273-
use_token_proxy=False,
273+
enable_azure_proxy=False,
274274
)
275275
mock_get_transport.assert_not_called()
276276

sdk/identity/azure-identity/tests/test_workload_identity_credential_async.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ async def send(request, **kwargs):
7070

7171

7272
class TestWorkloadIdentityCredentialTokenProxyAsync:
73-
"""Async test cases for WorkloadIdentityCredential with use_token_proxy=True."""
73+
"""Async test cases for WorkloadIdentityCredential with enable_azure_proxy=True."""
7474

75-
def test_use_token_proxy_creates_custom_aiohttp_transport(self):
76-
"""Test that use_token_proxy=True creates a custom aiohttp transport with correct parameters."""
75+
def test_enable_azure_proxy_creates_custom_aiohttp_transport(self):
76+
"""Test that enable_azure_proxy=True creates a custom aiohttp transport with correct parameters."""
7777
tenant_id = "tenant-id"
7878
client_id = "client-id"
7979
token_file_path = "foo-path"
@@ -96,7 +96,7 @@ def test_use_token_proxy_creates_custom_aiohttp_transport(self):
9696
tenant_id=tenant_id,
9797
client_id=client_id,
9898
token_file_path=token_file_path,
99-
use_token_proxy=True,
99+
enable_azure_proxy=True,
100100
)
101101

102102
mock_get_transport.assert_called_once_with(
@@ -106,8 +106,8 @@ def test_use_token_proxy_creates_custom_aiohttp_transport(self):
106106
ca_data=None,
107107
)
108108

109-
def test_use_token_proxy_with_ca_data(self):
110-
"""Test use_token_proxy with CA data instead of CA file."""
109+
def test_enable_azure_proxy_with_ca_data(self):
110+
"""Test enable_azure_proxy with CA data instead of CA file."""
111111
tenant_id = "tenant-id"
112112
client_id = "client-id"
113113
token_file_path = "foo-path"
@@ -128,7 +128,7 @@ def test_use_token_proxy_with_ca_data(self):
128128
tenant_id=tenant_id,
129129
client_id=client_id,
130130
token_file_path=token_file_path,
131-
use_token_proxy=True,
131+
enable_azure_proxy=True,
132132
)
133133
mock_get_transport.assert_called_once_with(
134134
sni=None,
@@ -137,8 +137,8 @@ def test_use_token_proxy_with_ca_data(self):
137137
ca_data=ca_data,
138138
)
139139

140-
def test_use_token_proxy_minimal_config(self):
141-
"""Test use_token_proxy with minimal configuration (only proxy endpoint)."""
140+
def test_enable_azure_proxy_minimal_config(self):
141+
"""Test enable_azure_proxy with minimal configuration (only proxy endpoint)."""
142142
tenant_id = "tenant-id"
143143
client_id = "client-id"
144144
token_file_path = "foo-path"
@@ -157,7 +157,7 @@ def test_use_token_proxy_minimal_config(self):
157157
tenant_id=tenant_id,
158158
client_id=client_id,
159159
token_file_path=token_file_path,
160-
use_token_proxy=True,
160+
enable_azure_proxy=True,
161161
)
162162

163163
mock_get_transport.assert_called_once_with(
@@ -167,8 +167,8 @@ def test_use_token_proxy_minimal_config(self):
167167
ca_data=None,
168168
)
169169

170-
def test_use_token_proxy_missing_proxy_endpoint(self):
171-
"""Test that use_token_proxy=True without proxy endpoint uses the normal transport."""
170+
def test_enable_azure_proxy_missing_proxy_endpoint(self):
171+
"""Test that enable_azure_proxy=True without proxy endpoint uses the normal transport."""
172172
tenant_id = "tenant-id"
173173
client_id = "client-id"
174174
token_file_path = "foo-path"
@@ -183,11 +183,11 @@ def test_use_token_proxy_missing_proxy_endpoint(self):
183183
tenant_id=tenant_id,
184184
client_id=client_id,
185185
token_file_path=token_file_path,
186-
use_token_proxy=True,
186+
enable_azure_proxy=True,
187187
)
188188
mock_get_transport.assert_not_called()
189189

190-
def test_use_token_proxy_both_ca_file_and_data_raises_error(self):
190+
def test_enable_azure_proxy_both_ca_file_and_data_raises_error(self):
191191
"""Test that setting both CA file and CA data raises ValueError."""
192192
tenant_id = "tenant-id"
193193
client_id = "client-id"
@@ -208,11 +208,11 @@ def test_use_token_proxy_both_ca_file_and_data_raises_error(self):
208208
tenant_id=tenant_id,
209209
client_id=client_id,
210210
token_file_path=token_file_path,
211-
use_token_proxy=True,
211+
enable_azure_proxy=True,
212212
)
213213

214-
def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self):
215-
"""Test that use_token_proxy=True without proxy endpoint but with other custom env vars raises ValueError."""
214+
def test_enable_azure_proxy_missing_endpoint_with_custom_env_vars_raises_error(self):
215+
"""Test that enable_azure_proxy=True without proxy endpoint but with other custom env vars raises ValueError."""
216216
tenant_id = "tenant-id"
217217
client_id = "client-id"
218218
token_file_path = "foo-path"
@@ -234,7 +234,7 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
234234
tenant_id=tenant_id,
235235
client_id=client_id,
236236
token_file_path=token_file_path,
237-
use_token_proxy=True,
237+
enable_azure_proxy=True,
238238
)
239239

240240
# Test with CA file set but no proxy endpoint
@@ -247,7 +247,7 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
247247
tenant_id=tenant_id,
248248
client_id=client_id,
249249
token_file_path=token_file_path,
250-
use_token_proxy=True,
250+
enable_azure_proxy=True,
251251
)
252252

253253
# Test with CA data set but no proxy endpoint
@@ -260,12 +260,12 @@ def test_use_token_proxy_missing_endpoint_with_custom_env_vars_raises_error(self
260260
tenant_id=tenant_id,
261261
client_id=client_id,
262262
token_file_path=token_file_path,
263-
use_token_proxy=True,
263+
enable_azure_proxy=True,
264264
)
265265

266266
@pytest.mark.asyncio
267267
@pytest.mark.parametrize("get_token_method", GET_TOKEN_METHODS)
268-
async def test_use_token_proxy_get_token_success(self, get_token_method):
268+
async def test_enable_azure_proxy_get_token_success(self, get_token_method):
269269
"""Test successful token acquisition when using token proxy."""
270270
tenant_id = "tenant-id"
271271
client_id = "client-id"
@@ -294,7 +294,7 @@ async def send(request, **kwargs):
294294
tenant_id=tenant_id,
295295
client_id=client_id,
296296
token_file_path=token_file_path,
297-
use_token_proxy=True,
297+
enable_azure_proxy=True,
298298
)
299299

300300
open_mock = mock_open(read_data=assertion)
@@ -304,8 +304,8 @@ async def send(request, **kwargs):
304304

305305
open_mock.assert_called_once_with(token_file_path, encoding="utf-8")
306306

307-
def test_use_token_proxy_false_does_not_create_transport(self):
308-
"""Test that use_token_proxy=False (default) does not create a custom transport."""
307+
def test_enable_azure_proxy_false_does_not_create_transport(self):
308+
"""Test that enable_azure_proxy=False (default) does not create a custom transport."""
309309
tenant_id = "tenant-id"
310310
client_id = "client-id"
311311
token_file_path = "foo-path"
@@ -315,7 +315,7 @@ def test_use_token_proxy_false_does_not_create_transport(self):
315315
tenant_id=tenant_id,
316316
client_id=client_id,
317317
token_file_path=token_file_path,
318-
use_token_proxy=False,
318+
enable_azure_proxy=False,
319319
)
320320
mock_get_transport.assert_not_called()
321321

0 commit comments

Comments
 (0)