Skip to content

Commit e0da29a

Browse files
authored
Fix gitguardian warning caused by "hello world" secret used in unit test (#1010)
## Changes Replace the plain encoded string by base64.b64encode to mitigate the gitguardian warning. ### Linked issues <!-- DOC: Link issue with a keyword: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved. See https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword --> Resolves #.. ### Functionality - [ ] added relevant user documentation - [ ] added new CLI command - [ ] modified existing command: `databricks labs ucx ...` - [ ] added a new workflow - [ ] modified existing workflow: `...` - [ ] added a new table - [ ] modified existing table: `...` ### Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [ ] manually tested - [ ] added unit tests - [ ] added integration tests - [ ] verified on staging environment (screenshot attached)
1 parent 18a7d2d commit e0da29a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/unit/azure/test_credentials.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
import logging
23
import re
34
from unittest.mock import create_autospec
@@ -254,7 +255,9 @@ def test_validate_storage_credentials_failed_operation(credential_manager):
254255

255256
@pytest.fixture
256257
def sp_migration(ws, installation, credential_manager):
257-
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
258+
ws.secrets.get_secret.return_value = GetSecretResponse(
259+
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
260+
)
258261

259262
arp = AzureResourcePermissions(
260263
installation, ws, create_autospec(AzureResources), create_autospec(ExternalLocations)
@@ -288,7 +291,10 @@ def test_for_cli(ws, installation):
288291

289292
@pytest.mark.parametrize(
290293
"secret_bytes_value, num_migrated",
291-
[(GetSecretResponse(value="aGVsbG8gd29ybGQ="), 1), (GetSecretResponse(value="T2zhLCBNdW5kbyE="), 0)],
294+
[
295+
(GetSecretResponse(value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")), 1),
296+
(GetSecretResponse(value=base64.b64encode("Olá, Mundo".encode("iso-8859-1")).decode("iso-8859-1")), 0),
297+
],
292298
)
293299
def test_read_secret_value_decode(ws, sp_migration, secret_bytes_value, num_migrated):
294300
ws.secrets.get_secret.return_value = secret_bytes_value
@@ -316,7 +322,9 @@ def test_read_secret_read_exception(caplog, ws, sp_migration):
316322

317323
def test_print_action_plan(caplog, ws, sp_migration):
318324
caplog.set_level(logging.INFO)
319-
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
325+
ws.secrets.get_secret.return_value = GetSecretResponse(
326+
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
327+
)
320328

321329
prompts = MockPrompts({"Above Azure Service Principals will be migrated to UC storage credentials*": "Yes"})
322330

@@ -331,7 +339,9 @@ def test_print_action_plan(caplog, ws, sp_migration):
331339

332340

333341
def test_run_without_confirmation(ws, sp_migration):
334-
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
342+
ws.secrets.get_secret.return_value = GetSecretResponse(
343+
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
344+
)
335345
prompts = MockPrompts(
336346
{
337347
"Above Azure Service Principals will be migrated to UC storage credentials*": "No",

0 commit comments

Comments
 (0)