diff --git a/.evergreen/generated_configs/tasks.yml b/.evergreen/generated_configs/tasks.yml index e91d2c119..79594da77 100644 --- a/.evergreen/generated_configs/tasks.yml +++ b/.evergreen/generated_configs/tasks.yml @@ -128,6 +128,10 @@ tasks: - mongo-python-driver - ${github_commit} working_dir: src + include_expansions_in_env: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN type: test # Coverage report tests diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 809792679..1bd54b80a 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -896,7 +896,8 @@ def create_backport_pr_tasks(): "mongo-python-driver", "${github_commit}", ] - cmd = get_subprocess_exec(args=args) + include_expansions = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] + cmd = get_subprocess_exec(args=args, include_expansions_in_env=include_expansions) assume_func = FunctionCall(func="assume ec2 role") return [EvgTask(name=name, commands=[assume_func, cmd], allowed_requesters=["commit"])] diff --git a/.evergreen/scripts/setup-system.sh b/.evergreen/scripts/setup-system.sh index d8552e0ad..9158414cc 100755 --- a/.evergreen/scripts/setup-system.sh +++ b/.evergreen/scripts/setup-system.sh @@ -38,4 +38,14 @@ if [ "$(uname -s)" = "Darwin" ]; then fi fi +if [ -w /etc/hosts ]; then + SUDO="" +else + SUDO="sudo" +fi + +# Add 'server' and 'hostname_not_in_cert' as a hostnames +echo "127.0.0.1 server" | $SUDO tee -a /etc/hosts +echo "127.0.0.1 hostname_not_in_cert" | $SUDO tee -a /etc/hosts + echo "Setting up system... done." diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4ae38d6a2..d1934183d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # v3 + uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} @@ -63,6 +63,6 @@ jobs: pip install -e . - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # v3 + uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 1d58c0d5f..6d9506776 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -18,4 +18,4 @@ jobs: with: persist-credentials: false - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@1c7106082dbc1753372e3924b7da1b9417011a21 + uses: zizmorcore/zizmor-action@0f0557ab4a0b31211d42435e42df31cbd63fdd59 diff --git a/doc/changelog.rst b/doc/changelog.rst index 2fd1bdd6b..933e2922d 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -13,6 +13,7 @@ PyMongo 4.14 brings a number of changes including: - Introduces a minor breaking change. When encoding :class:`bson.binary.BinaryVector`, a ``ValueError`` will be raised if the 'padding' metadata field is < 0 or > 7, or non-zero for any type other than PACKED_BIT. +- Changed :meth:`~pymongo.uri_parser.parse_uri`'s ``options`` parameter to be type ``dict`` instead of ``_CaseInsensitiveDictionary``. Changes in Version 4.13.2 (2025/06/17) -------------------------------------- diff --git a/pymongo/asynchronous/uri_parser.py b/pymongo/asynchronous/uri_parser.py index 11a6a6299..055b04d75 100644 --- a/pymongo/asynchronous/uri_parser.py +++ b/pymongo/asynchronous/uri_parser.py @@ -80,6 +80,9 @@ async def parse_uri( wait for a response from the DNS server. :param srv_service_name: A custom SRV service name + .. versionchanged:: 4.14 + ``options`` is now type ``dict`` as opposed to a ``_CaseInsensitiveDictionary``. + .. versionchanged:: 4.6 The delimiting slash (``/``) between hosts and connection options is now optional. For example, "mongodb://example.com?tls=true" is now a valid URI. diff --git a/pymongo/synchronous/uri_parser.py b/pymongo/synchronous/uri_parser.py index da0f86d72..45c175295 100644 --- a/pymongo/synchronous/uri_parser.py +++ b/pymongo/synchronous/uri_parser.py @@ -80,6 +80,9 @@ def parse_uri( wait for a response from the DNS server. :param srv_service_name: A custom SRV service name + .. versionchanged:: 4.14 + ``options`` is now type ``dict`` as opposed to a ``_CaseInsensitiveDictionary``. + .. versionchanged:: 4.6 The delimiting slash (``/``) between hosts and connection options is now optional. For example, "mongodb://example.com?tls=true" is now a valid URI. diff --git a/test/asynchronous/test_ssl.py b/test/asynchronous/test_ssl.py index a05bc9379..0ce3e8bba 100644 --- a/test/asynchronous/test_ssl.py +++ b/test/asynchronous/test_ssl.py @@ -304,8 +304,13 @@ class TestSSL(AsyncIntegrationTest): client = self.simple_client(uri_fmt % (CLIENT_PEM, "true", CA_PEM)) await self.assertClientWorks(client) + @unittest.skipIf( + "PyPy" in sys.version and not _IS_SYNC, + "https://github.com/pypy/pypy/issues/5131 flaky on async PyPy due to SSL EOF", + ) @async_client_context.require_tlsCertificateKeyFile @async_client_context.require_server_resolvable + @async_client_context.require_no_api_version @ignore_deprecations async def test_cert_ssl_validation_hostname_matching(self): # Expects the server to be running with server.pem and ca.pem @@ -430,8 +435,13 @@ class TestSSL(AsyncIntegrationTest): self.simple_client(uri_fmt % (CRL_PEM, CA_PEM), **self.credentials) # type: ignore[arg-type] ) + @unittest.skipIf( + "PyPy" in sys.version and not _IS_SYNC, + "https://github.com/pypy/pypy/issues/5131 flaky on async PyPy due to SSL EOF", + ) @async_client_context.require_tlsCertificateKeyFile @async_client_context.require_server_resolvable + @async_client_context.require_no_api_version @ignore_deprecations async def test_validation_with_system_ca_certs(self): # Expects the server to be running with server.pem and ca.pem. diff --git a/test/test_ssl.py b/test/test_ssl.py index 3ac0a4555..b1e9a65eb 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -304,8 +304,13 @@ class TestSSL(IntegrationTest): client = self.simple_client(uri_fmt % (CLIENT_PEM, "true", CA_PEM)) self.assertClientWorks(client) + @unittest.skipIf( + "PyPy" in sys.version and not _IS_SYNC, + "https://github.com/pypy/pypy/issues/5131 flaky on async PyPy due to SSL EOF", + ) @client_context.require_tlsCertificateKeyFile @client_context.require_server_resolvable + @client_context.require_no_api_version @ignore_deprecations def test_cert_ssl_validation_hostname_matching(self): # Expects the server to be running with server.pem and ca.pem @@ -430,8 +435,13 @@ class TestSSL(IntegrationTest): self.simple_client(uri_fmt % (CRL_PEM, CA_PEM), **self.credentials) # type: ignore[arg-type] ) + @unittest.skipIf( + "PyPy" in sys.version and not _IS_SYNC, + "https://github.com/pypy/pypy/issues/5131 flaky on async PyPy due to SSL EOF", + ) @client_context.require_tlsCertificateKeyFile @client_context.require_server_resolvable + @client_context.require_no_api_version @ignore_deprecations def test_validation_with_system_ca_certs(self): # Expects the server to be running with server.pem and ca.pem. diff --git a/test/test_uri_parser.py b/test/test_uri_parser.py index ed1a53ea2..502faf82b 100644 --- a/test/test_uri_parser.py +++ b/test/test_uri_parser.py @@ -555,6 +555,10 @@ class TestURI(unittest.TestCase): with self.assertRaisesRegex(ValueError, r"Port contains whitespace character: '\\n'"): parse_uri("mongodb://localhost:27\n017") + def test_parse_uri_options_type(self): + opts = parse_uri("mongodb://localhost:27017")["options"] + self.assertIsInstance(opts, dict) + if __name__ == "__main__": unittest.main()