Skip to content

Commit bbf4547

Browse files
authored
Merge branch 'main' into DRIVERS-2917
2 parents b4f672c + 380d864 commit bbf4547

File tree

94 files changed

+4653
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+4653
-614
lines changed

.evergreen/config.yml

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,46 @@ post_timeout_secs: 1800 # 5 minutes
1414
include:
1515
- filename: .evergreen/functions.yml
1616

17+
# Encryption-specific functions
18+
"start csfle servers":
19+
- command: ec2.assume_role
20+
params:
21+
role_arn: ${aws_test_secrets_role}
22+
- command: subprocess.exec
23+
params:
24+
binary: bash
25+
include_expansions_in_env: [
26+
"AWS_SECRET_ACCESS_KEY",
27+
"AWS_ACCESS_KEY_ID",
28+
"AWS_SESSION_TOKEN",
29+
]
30+
args:
31+
- ${DRIVERS_TOOLS}/.evergreen/csfle/setup.sh
32+
33+
"teardown csfle":
34+
- command: subprocess.exec
35+
params:
36+
binary: bash
37+
args:
38+
- ${DRIVERS_TOOLS}/.evergreen/csfle/teardown.sh
39+
40+
"run encryption tests":
41+
- command: subprocess.exec
42+
type: test
43+
params:
44+
binary: bash
45+
working_dir: "src"
46+
include_expansions_in_env: [
47+
"AWS_KMS_ARN",
48+
"DRIVERS_TOOLS",
49+
"MONGODB_URI",
50+
"DJANGO_SETTINGS_MODULE",
51+
"CRYPT_SHARED_LIB_PATH",
52+
]
53+
args:
54+
- ./.evergreen/run-tests.sh
55+
- encryption
56+
1757
pre:
1858
- func: setup
1959
- func: bootstrap mongo-orchestration
@@ -31,24 +71,29 @@ tasks:
3171
- func: "run performance tests"
3272
- func: "attach benchmark test results"
3373
- func: "send dashboard data"
74+
- name: run-encryption-tests
75+
commands:
76+
- func: "start csfle servers"
77+
- func: "run encryption tests"
78+
- func: "teardown csfle"
3479

3580
buildvariants:
36-
- name: tests-6-noauth-nossl
37-
display_name: Run Tests 6.0 NoAuth NoSSL
81+
- name: tests-7-noauth-nossl
82+
display_name: Run Tests 7.0 NoAuth NoSSL
3883
run_on: rhel87-small
3984
expansions:
40-
MONGODB_VERSION: "6.0"
85+
MONGODB_VERSION: "7.0"
4186
TOPOLOGY: server
4287
AUTH: "noauth"
4388
SSL: "nossl"
4489
tasks:
4590
- name: run-tests
4691

47-
- name: tests-6-auth-ssl
48-
display_name: Run Tests 6.0 Auth SSL
92+
- name: tests-7-auth-ssl
93+
display_name: Run Tests 7.0 Auth SSL
4994
run_on: rhel87-small
5095
expansions:
51-
MONGODB_VERSION: "6.0"
96+
MONGODB_VERSION: "7.0"
5297
TOPOLOGY: server
5398
AUTH: "auth"
5499
SSL: "ssl"
@@ -84,3 +129,22 @@ buildvariants:
84129
batchtime: 1440
85130
tasks:
86131
- name: perf-tests
132+
- name: tests-8-qe-local
133+
display_name: Run Tests 8.2 QE local KMS
134+
run_on: rhel87-small
135+
expansions:
136+
MONGODB_VERSION: "8.2"
137+
TOPOLOGY: replica_set
138+
DJANGO_SETTINGS_MODULE: "encrypted_settings"
139+
tasks:
140+
- name: run-encryption-tests
141+
142+
- name: tests-8-qe-aws
143+
display_name: Run Tests 8.2 QE AWS KMS
144+
run_on: rhel87-small
145+
expansions:
146+
MONGODB_VERSION: "8.2"
147+
TOPOLOGY: replica_set
148+
DJANGO_SETTINGS_MODULE: "encrypted_aws_settings"
149+
tasks:
150+
- name: run-encryption-tests

.evergreen/run-tests.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
set -eux
44

5-
# Install django-mongodb-backend
6-
/opt/python/3.10/bin/python3 -m venv venv
5+
# Export secrets as environment variables
6+
# https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/csfle/README.md#usage
7+
if [[ "${1:-}" == "encryption" ]]; then
8+
. ../secrets-export.sh
9+
fi
10+
11+
# Set up virtual environment
12+
/opt/python/3.12/bin/python3 -m venv venv
713
. venv/bin/activate
814
python -m pip install -U pip
9-
pip install -e .
15+
16+
# Install django-mongodb-backend
17+
if [[ "${1:-}" == "encryption" ]]; then
18+
# Install encryption dependencies for the Queryable Encryption build
19+
pip install -e '.[encryption]'
20+
else
21+
pip install -e .
22+
fi
1023

1124
# Install django and test dependencies
12-
git clone --branch mongodb-5.2.x https://github.com/mongodb-forks/django django_repo
25+
git clone --branch mongodb-6.0.x https://github.com/mongodb-forks/django django_repo
1326
pushd django_repo/tests/
1427
pip install -e ..
1528
pip install -r requirements/py3.txt

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "weekly"
8+
cooldown:
9+
default-days: 7
810
groups:
911
actions:
1012
patterns:

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656

5757
# Initializes the CodeQL tools for scanning.
5858
- name: Initialize CodeQL
59-
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
59+
uses: github/codeql-action/init@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
6060
with:
6161
languages: ${{ matrix.language }}
6262
build-mode: none
@@ -72,6 +72,6 @@ jobs:
7272
pip install -e .
7373
7474
- name: Perform CodeQL Analysis
75-
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
75+
uses: github/codeql-action/analyze@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
7676
with:
7777
category: "/language:${{ matrix.language }}"

.github/workflows/dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Create packages
3333
run: python -m build .
3434
- name: Store package artifacts
35-
uses: actions/upload-artifact@v5
35+
uses: actions/upload-artifact@v6
3636
with:
3737
name: all-dist-${{ github.run_id }}
3838
path: "dist/*"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Settings for django_mongodb_backend/tests with AWS Key Management System.
2+
import os
3+
4+
from encrypted_settings import * # noqa: F403
5+
from pymongo.encryption import AutoEncryptionOpts
6+
7+
DATABASES["encrypted"] = { # noqa: F405
8+
"ENGINE": "django_mongodb_backend",
9+
"NAME": "djangotests_encrypted",
10+
"OPTIONS": {
11+
"auto_encryption_opts": AutoEncryptionOpts(
12+
key_vault_namespace="djangotests_encrypted.__keyVault",
13+
kms_providers={
14+
"aws": {
15+
"accessKeyId": os.environ["AWS_ACCESS_KEY_ID"],
16+
"secretAccessKey": os.environ["AWS_SECRET_ACCESS_KEY"],
17+
}
18+
},
19+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
20+
crypt_shared_lib_required=True,
21+
),
22+
},
23+
"KMS_CREDENTIALS": {
24+
"aws": {
25+
"key": os.environ["AWS_KMS_ARN"],
26+
"region": os.environ["AWS_DEFAULT_REGION"],
27+
}
28+
},
29+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Settings for django_mongodb_backend/tests when encryption is supported.
2+
import os
3+
4+
from mongodb_settings import * # noqa: F403
5+
from pymongo.encryption import AutoEncryptionOpts
6+
7+
DATABASES["encrypted"] = { # noqa: F405
8+
"ENGINE": "django_mongodb_backend",
9+
"NAME": "djangotests_encrypted",
10+
"OPTIONS": {
11+
"auto_encryption_opts": AutoEncryptionOpts(
12+
key_vault_namespace="djangotests_encrypted.__keyVault",
13+
kms_providers={"local": {"key": os.urandom(96)}},
14+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
15+
crypt_shared_lib_required=True,
16+
),
17+
"directConnection": True,
18+
},
19+
}
20+
21+
22+
class EncryptedRouter:
23+
def db_for_read(self, model, **hints):
24+
# All models in the encryption_ app use the encrypted database.
25+
if model._meta.app_label == "encryption_":
26+
return "encrypted"
27+
return None
28+
29+
db_for_write = db_for_read
30+
31+
def allow_migrate(self, db, app_label, model_name=None, **hints):
32+
# Create the encryption_ app's models only in the encrypted database.
33+
if app_label == "encryption_":
34+
return db == "encrypted"
35+
# Don't create other apps' models in the encrypted database.
36+
if db == "encrypted":
37+
return False
38+
return None
39+
40+
41+
DATABASE_ROUTERS.append(EncryptedRouter()) # noqa: F405

.github/workflows/linters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
persist-credentials: false
1818
- uses: actions/setup-python@v6
1919
with:
20-
python-version: '3.10'
20+
python-version: '3.12'
2121
cache: 'pip'
2222
cache-dependency-path: 'pyproject.toml'
2323
- name: Install Python dependencies
@@ -39,7 +39,7 @@ jobs:
3939
with:
4040
cache: 'pip'
4141
cache-dependency-path: 'pyproject.toml'
42-
python-version: '3.10'
42+
python-version: '3.12'
4343
- name: Install dependencies
4444
run: |
4545
pip install -U pip
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Settings for django_mongodb_backend/tests.
1+
# Settings for django_mongodb_backend/tests when encryption isn't supported.
22
from django_settings import * # noqa: F403
33

4+
DATABASES["encrypted"] = {} # noqa: F405
45
DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"]

.github/workflows/release-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
id-token: write
7676
steps:
7777
- name: Download all the dists
78-
uses: actions/download-artifact@v6
78+
uses: actions/download-artifact@v7
7979
with:
8080
name: all-dist-${{ github.run_id }}
8181
path: dist/

0 commit comments

Comments
 (0)