Skip to content

Commit

Permalink
[Storage] Move test keys into CredScan-suppressed helper files (#20330)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored Sep 2, 2021
1 parent 45df88b commit 15cd636
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 104 deletions.
4 changes: 2 additions & 2 deletions eng/CredScanSuppression.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"sdk/identity/azure-identity/tests/certificate.pfx",
"sdk/identity/azure-identity/tests/certificate-with-password.pfx",
"sdk/core/azure-servicemanagement-legacy/tests/legacy_mgmt_settings_fake.py",
"sdk/storage/azure-storage-blob/tests/blob_settings_fake.py",
"sdk/storage/azure-storage-file-datalake/tests/data_lake_settings_fake.py",
"sdk/storage/azure-storage-blob/tests/fake_credentials.py",
"sdk/storage/azure-storage-file-datalake/tests/fake_credentials.py",
"tools/azure-sdk-tools/devtools_testutils/mgmt_settings_fake.py"
],
"_justification": "File contains private key used by test code."
Expand Down
53 changes: 0 additions & 53 deletions sdk/storage/azure-storage-blob/tests/blob_settings_fake.py

This file was deleted.

8 changes: 8 additions & 0 deletions sdk/storage/azure-storage-blob/tests/fake_credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

CPK_KEY_VALUE = "MDEyMzQ1NjcwMTIzNDU2NzAxMjM0NTY3MDEyMzQ1Njc="
CPK_KEY_HASH = "3QFFFpRA5+XANHqwwbT4yXDmrT/2JaLt/FKHjzhOdoE="
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ResourceTypes,
AccountSasPermissions, generate_container_sas, ContainerClient, CustomerProvidedEncryptionKey,
)
from fake_credentials import CPK_KEY_HASH, CPK_KEY_VALUE
from _shared.testcase import GlobalStorageAccountPreparer
from devtools_testutils.storage import StorageTestCase

Expand Down Expand Up @@ -862,8 +863,7 @@ def test_if_blob_with_cpk_exists(self, resource_group, location, storage_account
connection_data_block_size=4 * 1024)
cc.create_container()
self._setup()
test_cpk = CustomerProvidedEncryptionKey(key_value="MDEyMzQ1NjcwMTIzNDU2NzAxMjM0NTY3MDEyMzQ1Njc=",
key_hash="3QFFFpRA5+XANHqwwbT4yXDmrT/2JaLt/FKHjzhOdoE=")
test_cpk = CustomerProvidedEncryptionKey(key_value=CPK_KEY_VALUE, key_hash=CPK_KEY_HASH)
blob_client = cc.get_blob_client("test_blob")
blob_client.upload_blob(b"hello world", cpk=test_cpk)
# Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
AccessPolicy, generate_account_sas, ResourceTypes, AccountSasPermissions, generate_blob_sas, BlobSasPermissions,
generate_container_sas, CustomerProvidedEncryptionKey,
)
from fake_credentials import CPK_KEY_HASH, CPK_KEY_VALUE
from _shared.testcase import GlobalStorageAccountPreparer
from devtools_testutils.storage.aio import AsyncStorageTestCase

Expand Down Expand Up @@ -884,8 +885,7 @@ async def test_if_blob_with_cpk_exists(self, resource_group, location, storage_a
connection_data_block_size=4 * 1024)
await cc.create_container()
self._setup()
test_cpk = CustomerProvidedEncryptionKey(key_value="MDEyMzQ1NjcwMTIzNDU2NzAxMjM0NTY3MDEyMzQ1Njc=",
key_hash="3QFFFpRA5+XANHqwwbT4yXDmrT/2JaLt/FKHjzhOdoE=")
test_cpk = CustomerProvidedEncryptionKey(key_value=CPK_KEY_VALUE, key_hash=CPK_KEY_HASH)
blob_client = cc.get_blob_client("test_blob")
await blob_client.upload_blob(b"hello world", cpk=test_cpk)
# Act
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

STORAGE_DATA_LAKE_ACCOUNT_FAKE_KEY = "NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg=="
3 changes: 2 additions & 1 deletion sdk/storage/azure-storage-file-datalake/tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from azure_devtools.scenario_tests import RecordingProcessor
from devtools_testutils import AzureTestCase, PowerShellPreparer
from fake_credentials import STORAGE_DATA_LAKE_ACCOUNT_FAKE_KEY

try:
from cStringIO import StringIO # Python 2
Expand All @@ -38,7 +39,7 @@
DataLakePreparer = functools.partial(
PowerShellPreparer, "storage",
datalake_storage_account_name="storagename",
datalake_storage_account_key="NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg=="
datalake_storage_account_key=STORAGE_DATA_LAKE_ACCOUNT_FAKE_KEY
)


Expand Down

0 comments on commit 15cd636

Please sign in to comment.