Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gitguardian warning caused by "hello world" secret used in unit test #1010

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tests/unit/azure/test_credentials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
import logging
import re
from unittest.mock import create_autospec
Expand Down Expand Up @@ -254,7 +255,9 @@ def test_validate_storage_credentials_failed_operation(credential_manager):

@pytest.fixture
def sp_migration(ws, installation, credential_manager):
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
ws.secrets.get_secret.return_value = GetSecretResponse(
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
)

arp = AzureResourcePermissions(
installation, ws, create_autospec(AzureResources), create_autospec(ExternalLocations)
Expand Down Expand Up @@ -288,7 +291,10 @@ def test_for_cli(ws, installation):

@pytest.mark.parametrize(
"secret_bytes_value, num_migrated",
[(GetSecretResponse(value="aGVsbG8gd29ybGQ="), 1), (GetSecretResponse(value="T2zhLCBNdW5kbyE="), 0)],
[
(GetSecretResponse(value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")), 1),
(GetSecretResponse(value=base64.b64encode("Olá, Mundo".encode("iso-8859-1")).decode("iso-8859-1")), 0),
],
)
def test_read_secret_value_decode(ws, sp_migration, secret_bytes_value, num_migrated):
ws.secrets.get_secret.return_value = secret_bytes_value
Expand Down Expand Up @@ -316,7 +322,9 @@ def test_read_secret_read_exception(caplog, ws, sp_migration):

def test_print_action_plan(caplog, ws, sp_migration):
caplog.set_level(logging.INFO)
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
ws.secrets.get_secret.return_value = GetSecretResponse(
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
)

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

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


def test_run_without_confirmation(ws, sp_migration):
ws.secrets.get_secret.return_value = GetSecretResponse(value="aGVsbG8gd29ybGQ=")
ws.secrets.get_secret.return_value = GetSecretResponse(
value=base64.b64encode("hello world".encode("utf-8")).decode("utf-8")
)
prompts = MockPrompts(
{
"Above Azure Service Principals will be migrated to UC storage credentials*": "No",
Expand Down
Loading