Skip to content

Commit 38839d6

Browse files
committed
fail loudly & avoid uppercased values in settings
1 parent 01607a6 commit 38839d6

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

.evergreen/config.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,22 @@ buildvariants:
140140
tasks:
141141
- name: run-tests
142142

143-
- name: tests-8-qe
144-
display_name: Run Tests 8.2 QE
143+
- name: tests-8-qe-local
144+
display_name: Run Tests 8.2 QE local KMS
145145
run_on: rhel87-small
146146
expansions:
147147
MONGODB_VERSION: "8.2"
148148
TOPOLOGY: replica_set
149-
DJANGO_SETTINGS_MODULE: "encrypted_settings"
149+
DJANGO_SETTINGS_MODULE: "local_kms_encrypted_settings"
150+
tasks:
151+
- name: run-encryption-tests
152+
153+
- name: tests-8-qe-aws
154+
display_name: Run Tests 8.2 QE aws KMS
155+
run_on: rhel87-small
156+
expansions:
157+
MONGODB_VERSION: "8.2"
158+
TOPOLOGY: replica_set
159+
DJANGO_SETTINGS_MODULE: "aws_kms_encrypted_settings"
150160
tasks:
151161
- name: run-encryption-tests
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from local_kms_encrypted_settings import * # noqa: F403
2+
3+
DATABASES["encrypted"] = { # noqa: F405
4+
"ENGINE": "django_mongodb_backend",
5+
"NAME": "djangotests_encrypted",
6+
"OPTIONS": {
7+
"auto_encryption_opts": AutoEncryptionOpts( # noqa: F405
8+
key_vault_namespace="djangotests_encrypted.__keyVault",
9+
kms_providers={
10+
"aws": {
11+
"accessKeyId": os.environ.get("FLE_AWS_KEY"), # noqa: F405
12+
"secretAccessKey": os.environ.get("FLE_AWS_SECRET"), # noqa: F405
13+
}
14+
},
15+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"], # noqa: F405
16+
crypt_shared_lib_required=True,
17+
),
18+
"directConnection": True,
19+
},
20+
"KMS_CREDENTIALS": {
21+
"aws": {
22+
"key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0",
23+
"region": "us-east-1",
24+
}
25+
},
26+
}

.github/workflows/encrypted_settings.py renamed to .github/workflows/local_kms_encrypted_settings.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,18 @@
77

88
os.environ["LD_LIBRARY_PATH"] = str(Path(os.environ["CRYPT_SHARED_LIB_PATH"]).parent)
99

10-
AWS_CREDS = {
11-
"accessKeyId": os.environ.get("FLE_AWS_KEY", ""),
12-
"secretAccessKey": os.environ.get("FLE_AWS_SECRET", ""),
13-
}
14-
15-
_USE_AWS_KMS = any(AWS_CREDS.values())
16-
17-
if _USE_AWS_KMS:
18-
_AWS_REGION = os.environ.get("FLE_AWS_KMS_REGION", "us-east-1")
19-
_AWS_KEY_ARN = os.environ.get(
20-
"FLE_AWS_KMS_KEY_ARN",
21-
"arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0",
22-
)
23-
KMS_PROVIDERS = {"aws": AWS_CREDS}
24-
KMS_CREDENTIALS = {"aws": {"key": _AWS_KEY_ARN, "region": _AWS_REGION}}
25-
else:
26-
KMS_PROVIDERS = {"local": {"key": os.urandom(96)}}
27-
KMS_CREDENTIALS = {"local": {}}
28-
2910
DATABASES["encrypted"] = { # noqa: F405
3011
"ENGINE": "django_mongodb_backend",
3112
"NAME": "djangotests_encrypted",
3213
"OPTIONS": {
3314
"auto_encryption_opts": AutoEncryptionOpts(
3415
key_vault_namespace="djangotests_encrypted.__keyVault",
35-
kms_providers=KMS_PROVIDERS,
16+
kms_providers={"local": {"key": os.urandom(96)}},
3617
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
37-
crypt_shared_lib_required=True,
3818
),
3919
"directConnection": True,
4020
},
41-
"KMS_CREDENTIALS": KMS_CREDENTIALS,
21+
"KMS_CREDENTIALS": {"local": {}},
4222
}
4323

4424

.github/workflows/test-python-atlas.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ jobs:
6161
permissions:
6262
contents: read
6363
env:
64-
DJANGO_SETTINGS_MODULE: "encrypted_settings"
64+
DJANGO_SETTINGS_MODULE: "local_kms_encrypted_settings"
6565
CRYPT_SHARED_LIB_PATH: "${{ github.workspace }}/lib/mongo_crypt_v1.so"

0 commit comments

Comments
 (0)