Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 65 additions & 18 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,71 @@ buildvariants:
COMPRESSORS: zstd
PYTHON_BINARY: /opt/python/pypy3.9/bin/python3

# Enterprise auth tests.
- name: enterprise-auth-macos-py3.9-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth macOS py3.9 Auth
run_on:
- macos-14
expansions:
AUTH: auth
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
- name: enterprise-auth-rhel8-py3.10-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth RHEL8 py3.10 Auth
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.10/bin/python3
- name: enterprise-auth-rhel8-py3.11-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth RHEL8 py3.11 Auth
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.11/bin/python3
- name: enterprise-auth-rhel8-py3.12-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth RHEL8 py3.12 Auth
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.12/bin/python3
- name: enterprise-auth-win64-py3.13-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth Win64 py3.13 Auth
run_on:
- windows-64-vsMulti-small
expansions:
AUTH: auth
PYTHON_BINARY: C:/python/Python313/python.exe
- name: enterprise-auth-rhel8-pypy3.9-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth RHEL8 pypy3.9 Auth
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/pypy3.9/bin/python3
- name: enterprise-auth-rhel8-pypy3.10-auth
tasks:
- name: test-enterprise-auth
display_name: Enterprise Auth RHEL8 pypy3.10 Auth
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3

- matrix_name: "tests-fips"
matrix_spec:
platform:
Expand Down Expand Up @@ -3350,24 +3415,6 @@ buildvariants:
tasks:
- ".latest"

- matrix_name: "test-linux-enterprise-auth"
matrix_spec:
platform: rhel8
python-version: "*"
auth: "auth"
display_name: "Enterprise ${auth} ${platform} ${python-version}"
tasks:
- name: "test-enterprise-auth"

- matrix_name: "tests-windows-enterprise-auth"
matrix_spec:
platform: windows
python-version-windows: "*"
auth: "auth"
display_name: "Enterprise ${auth} ${platform} ${python-version-windows}"
tasks:
- name: "test-enterprise-auth"

- matrix_name: "test-search-index-helpers"
matrix_spec:
platform: rhel8
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ if [ -n "$TEST_ENTERPRISE_AUTH" ]; then
export GSSAPI_HOST=${SASL_HOST}
export GSSAPI_PORT=${SASL_PORT}
export GSSAPI_PRINCIPAL=${PRINCIPAL}

export TEST_SUITES="auth"
fi

if [ -n "$TEST_LOADBALANCER" ]; then
Expand Down
23 changes: 22 additions & 1 deletion .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,31 @@ def create_compression_variants():
return variants


def create_enterprise_auth_variants():
expansions = dict(AUTH="auth")
variants = []

# All python versions across platforms.
for python in ALL_PYTHONS:
if python == CPYTHONS[0]:
host = "macos"
elif python == CPYTHONS[-1]:
host = "win64"
else:
host = "rhel8"
display_name = get_display_name("Enterprise Auth", host, python=python, **expansions)
variant = create_variant(
["test-enterprise-auth"], display_name, host=host, python=python, expansions=expansions
)
variants.append(variant)

return variants


##################
# Generate Config
##################

variants = create_compression_variants()
variants = create_enterprise_auth_variants()
# print(len(variants))
generate_yaml(variants=variants)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ filterwarnings = [
markers = [
"auth_aws: tests that rely on pymongo-auth-aws",
"auth_oidc: tests that rely on oidc auth",
"auth: tests that rely on authentication",
"ocsp: tests that rely on ocsp",
"atlas: tests that rely on atlas",
"data_lake: tests that rely on atlas data lake",
Expand Down
11 changes: 11 additions & 0 deletions test/asynchronous/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
)
from test.utils import AllowListEventListener, delay, ignore_deprecations

import pytest

from pymongo import AsyncMongoClient, monitoring
from pymongo.asynchronous.auth import HAVE_KERBEROS
from pymongo.auth_shared import _build_credentials_tuple
Expand Down Expand Up @@ -80,6 +82,7 @@ def run(self):


class TestGSSAPI(AsyncPyMongoTestCase):
pytestmark = pytest.mark.auth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can put this once at the top of the file to mark the whole module rather than each class individually.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I didn't think that would work with unittest classes, updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mech_properties: str
service_realm_required: bool

Expand Down Expand Up @@ -266,6 +269,8 @@ async def test_gssapi_threaded(self):


class TestSASLPlain(AsyncPyMongoTestCase):
pytestmark = pytest.mark.auth

@classmethod
def setUpClass(cls):
if not SASL_HOST or not SASL_USER or not SASL_PASS:
Expand Down Expand Up @@ -339,6 +344,8 @@ def auth_string(user, password):


class TestSCRAMSHA1(AsyncIntegrationTest):
pytestmark = pytest.mark.auth

@async_client_context.require_auth
async def asyncSetUp(self):
await super().asyncSetUp()
Expand Down Expand Up @@ -373,6 +380,8 @@ async def test_scram_sha1(self):

# https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst#scram-sha-256-and-mechanism-negotiation
class TestSCRAM(AsyncIntegrationTest):
pytestmark = pytest.mark.auth

@async_client_context.require_auth
@async_client_context.require_version_min(3, 7, 2)
async def asyncSetUp(self):
Expand Down Expand Up @@ -612,6 +621,8 @@ async def test_scram_threaded(self):


class TestAuthURIOptions(AsyncIntegrationTest):
pytestmark = pytest.mark.auth

@async_client_context.require_auth
async def asyncSetUp(self):
await super().asyncSetUp()
Expand Down
11 changes: 11 additions & 0 deletions test/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
)
from test.utils import AllowListEventListener, delay, ignore_deprecations

import pytest

from pymongo import MongoClient, monitoring
from pymongo.auth_shared import _build_credentials_tuple
from pymongo.errors import OperationFailure
Expand Down Expand Up @@ -80,6 +82,7 @@ def run(self):


class TestGSSAPI(PyMongoTestCase):
pytestmark = pytest.mark.auth
mech_properties: str
service_realm_required: bool

Expand Down Expand Up @@ -266,6 +269,8 @@ def test_gssapi_threaded(self):


class TestSASLPlain(PyMongoTestCase):
pytestmark = pytest.mark.auth

@classmethod
def setUpClass(cls):
if not SASL_HOST or not SASL_USER or not SASL_PASS:
Expand Down Expand Up @@ -339,6 +344,8 @@ def auth_string(user, password):


class TestSCRAMSHA1(IntegrationTest):
pytestmark = pytest.mark.auth

@client_context.require_auth
def setUp(self):
super().setUp()
Expand Down Expand Up @@ -371,6 +378,8 @@ def test_scram_sha1(self):

# https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst#scram-sha-256-and-mechanism-negotiation
class TestSCRAM(IntegrationTest):
pytestmark = pytest.mark.auth

@client_context.require_auth
@client_context.require_version_min(3, 7, 2)
def setUp(self):
Expand Down Expand Up @@ -608,6 +617,8 @@ def test_scram_threaded(self):


class TestAuthURIOptions(IntegrationTest):
pytestmark = pytest.mark.auth

@client_context.require_auth
def setUp(self):
super().setUp()
Expand Down
Loading