PYTHON-5373 test client auth on cloud-dev (#2423)

This commit is contained in:
Kevin Albertson 2025-07-09 11:56:42 -04:00 committed by GitHub
parent c77c15e369
commit 04f2cc0fa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 1 deletions

View File

@ -75,6 +75,8 @@ buildvariants:
display_name: Atlas connect RHEL8 display_name: Atlas connect RHEL8
run_on: run_on:
- rhel87-small - rhel87-small
expansions:
TEST_NAME: atlas_connect
tags: [pr] tags: [pr]
# Atlas data lake tests # Atlas data lake tests

View File

@ -425,6 +425,7 @@ def create_atlas_connect_variants():
get_variant_name("Atlas connect", host), get_variant_name("Atlas connect", host),
tags=["pr"], tags=["pr"],
host=DEFAULT_HOST, host=DEFAULT_HOST,
expansions=dict(TEST_NAME="atlas_connect"),
) )
] ]

View File

@ -417,7 +417,18 @@ def handle_test_env() -> None:
run_command(f"bash {auth_aws_dir}/setup-secrets.sh") run_command(f"bash {auth_aws_dir}/setup-secrets.sh")
if test_name == "atlas_connect": if test_name == "atlas_connect":
get_secrets("drivers/atlas_connect") secrets = get_secrets("drivers/atlas_connect")
# Write file with Atlas X509 client certificate:
decoded = base64.b64decode(secrets["ATLAS_X509_DEV_CERT_BASE64"]).decode("utf8")
cert_file = ROOT / ".evergreen/atlas_x509_dev_client_certificate.pem"
with cert_file.open("w") as file:
file.write(decoded)
write_env(
"ATLAS_X509_DEV_WITH_CERT",
secrets["ATLAS_X509_DEV"] + "&tlsCertificateKeyFile=" + str(cert_file),
)
# We do not want the default client_context to be initialized. # We do not want the default client_context to be initialized.
write_env("DISABLE_CONTEXT") write_env("DISABLE_CONTEXT")

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ expansion.yml
.evergreen/scripts/test-env.sh .evergreen/scripts/test-env.sh
specifications/ specifications/
results.json results.json
.evergreen/atlas_x509_dev_client_certificate.pem
# Lambda temp files # Lambda temp files
test/lambda/.aws-sam test/lambda/.aws-sam

View File

@ -42,6 +42,7 @@ URIS = {
"ATLAS_SRV_FREE": os.environ.get("ATLAS_SRV_FREE"), "ATLAS_SRV_FREE": os.environ.get("ATLAS_SRV_FREE"),
"ATLAS_SRV_TLS11": os.environ.get("ATLAS_SRV_TLS11"), "ATLAS_SRV_TLS11": os.environ.get("ATLAS_SRV_TLS11"),
"ATLAS_SRV_TLS12": os.environ.get("ATLAS_SRV_TLS12"), "ATLAS_SRV_TLS12": os.environ.get("ATLAS_SRV_TLS12"),
"ATLAS_X509_DEV_WITH_CERT": os.environ.get("ATLAS_X509_DEV_WITH_CERT"),
} }
@ -91,6 +92,9 @@ class TestAtlasConnect(PyMongoTestCase):
def test_srv_tls_12(self): def test_srv_tls_12(self):
self.connect_srv(URIS["ATLAS_SRV_TLS12"]) self.connect_srv(URIS["ATLAS_SRV_TLS12"])
def test_x509_with_cert(self):
self.connect(URIS["ATLAS_X509_DEV_WITH_CERT"])
def test_uniqueness(self): def test_uniqueness(self):
"""Ensure that we don't accidentally duplicate the test URIs.""" """Ensure that we don't accidentally duplicate the test URIs."""
uri_to_names = defaultdict(list) uri_to_names = defaultdict(list)