|
1 | 1 | import importlib
|
2 |
| -import os |
3 | 2 | from datetime import datetime, time, timedelta
|
4 | 3 | from io import StringIO
|
5 | 4 | from unittest.mock import patch
|
|
9 | 8 | from bson.binary import Binary
|
10 | 9 | from django.core.management import call_command
|
11 | 10 | from django.db import connections, models
|
12 |
| -from django.test import TestCase, TransactionTestCase, modify_settings, override_settings |
| 11 | +from django.test import TransactionTestCase, modify_settings, override_settings |
13 | 12 |
|
14 | 13 | from django_mongodb_backend.encryption import EqualityQuery
|
15 | 14 | from django_mongodb_backend.fields import EncryptedFieldMixin
|
@@ -351,51 +350,3 @@ def test_patient(self):
|
351 | 350 | self.assertEqual(len(list(patients)), 1)
|
352 | 351 | records = connections["other"].database.encryption__patientrecord.find()
|
353 | 352 | self.assertTrue("__safeContent__" in records[0])
|
354 |
| - |
355 |
| - |
356 |
| -class KMSCredentialsTests(TestCase): |
357 |
| - def test_env(self): |
358 |
| - with patch.dict(os.environ, {}, clear=True): |
359 |
| - encryption = reload_module("django_mongodb_backend.encryption") |
360 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["aws"]["key"], "") |
361 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["aws"]["region"], "") |
362 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["azure"]["keyName"], "") |
363 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["azure"]["keyVaultEndpoint"], "") |
364 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["projectId"], "") |
365 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["location"], "") |
366 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["keyRing"], "") |
367 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["keyName"], "") |
368 |
| - env = { |
369 |
| - "AWS_KEY_ARN": "TestArn", |
370 |
| - "AWS_KEY_REGION": "us-x-test", |
371 |
| - "AZURE_KEY_NAME": "azure-key", |
372 |
| - "AZURE_KEY_VAULT_ENDPOINT": "https://example.vault.azure.net/", |
373 |
| - "GCP_PROJECT_ID": "gcp-test-prj", |
374 |
| - "GCP_LOCATION": "test-loc", |
375 |
| - "GCP_KEY_RING": "ring1", |
376 |
| - "GCP_KEY_NAME": "gcp-key", |
377 |
| - } |
378 |
| - with patch.dict(os.environ, env, clear=True): |
379 |
| - encryption = reload_module("django_mongodb_backend.encryption") |
380 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["azure"]["keyName"], "azure-key") |
381 |
| - self.assertEqual( |
382 |
| - encryption.KMS_CREDENTIALS["azure"]["keyVaultEndpoint"], |
383 |
| - "https://example.vault.azure.net/", |
384 |
| - ) |
385 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["projectId"], "gcp-test-prj") |
386 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["location"], "test-loc") |
387 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["keyRing"], "ring1") |
388 |
| - self.assertEqual(encryption.KMS_CREDENTIALS["gcp"]["keyName"], "gcp-key") |
389 |
| - |
390 |
| - |
391 |
| -class KMSProvidersTests(TestCase): |
392 |
| - def test_env(self): |
393 |
| - with patch.dict(os.environ, {}, clear=True): |
394 |
| - encryption = reload_module("django_mongodb_backend.encryption") |
395 |
| - self.assertEqual(encryption.KMS_PROVIDERS["kmip"]["endpoint"], "not a valid endpoint") |
396 |
| - env = { |
397 |
| - "KMIP_KMS_ENDPOINT": "kmip://loc", |
398 |
| - } |
399 |
| - with patch.dict(os.environ, env, clear=True): |
400 |
| - encryption = reload_module("django_mongodb_backend.encryption") |
401 |
| - self.assertEqual(encryption.KMS_PROVIDERS["kmip"]["endpoint"], "kmip://loc") |
0 commit comments